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 >
2011-01-10 09:13:31 +01:00
* Copyright ( C ) 2004 - 2011 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 >
2011-01-10 09:13:31 +01:00
* Copyright ( C ) 2005 - 2011 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
2010-08-22 14:44:14 +02:00
@ ini_set ( 'memory_limit' , '64M' ); // This may be useless if memory is hard limited by your PHP
2010-02-28 03:01:46 +01:00
2008-11-28 00:02:49 +01:00
// For optionnal tuning. Enabled if environment variable DOL_TUNING is defined.
2010-02-19 14:50:49 +01:00
// A call first. Is the equivalent function dol_microtime_float not yet loaded.
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
}
2010-02-19 14:50:49 +01:00
// Forcing parameter setting magic_quotes_gpc and cleaning parameters
// (Otherwise he would have for each position, condition
// Reading stripslashes variable according to state get_magic_quotes_gpc).
// Off mode (recommended, you just do addslashes when an 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 );
2010-08-29 20:29:19 +02:00
// $_REQUEST = array_map('stripslashes_deep', $_REQUEST);
2009-05-18 00:40:24 +02:00
$_COOKIE = array_map ( 'stripslashes_deep' , $_COOKIE );
2010-11-20 14:08:44 +01:00
@ set_magic_quotes_runtime ( 0 );
2008-01-06 14:04:06 +01:00
}
2005-11-22 23:27:20 +01:00
}
2009-08-21 22:22:46 +02:00
2010-11-03 22:21:35 +01:00
// Security: SQL Injection and XSS Injection (scripts) protection (Filters on GET, POST)
2010-11-20 14:08:44 +01:00
function test_sql_and_script_inject ( $val , $get )
2007-01-19 19:25:10 +01:00
{
2008-09-30 02:10:49 +02:00
$sql_inj = 0 ;
2010-11-20 14:08:44 +01:00
// For SQL Injection
2009-10-24 08:10:00 +02:00
$sql_inj += preg_match ( '/delete[\s]+from/i' , $val );
$sql_inj += preg_match ( '/create[\s]+table/i' , $val );
2009-10-24 08:18:56 +02:00
$sql_inj += preg_match ( '/update.+set.+=/i' , $val );
2009-10-24 08:10:00 +02:00
$sql_inj += preg_match ( '/insert[\s]+into/i' , $val );
2009-10-24 08:18:56 +02:00
$sql_inj += preg_match ( '/select.+from/i' , $val );
2010-11-10 20:18:06 +01:00
$sql_inj += preg_match ( '/union.+select/i' , $val );
2010-11-20 14:08:44 +01:00
// For XSS Injection done by adding javascript with script
2009-10-24 08:10:00 +02:00
$sql_inj += preg_match ( '/<script/i' , $val );
2010-11-20 14:08:44 +01:00
// For XSS Injection done by adding javascript with onmousemove, etc... (closing a src or href tag with not cleaned param)
if ( $get ) $sql_inj += preg_match ( '/"/i' , $val ); // We refused " in GET parameters value
2008-09-30 02:10:49 +02:00
return $sql_inj ;
2007-01-19 19:25:10 +01:00
}
2010-11-20 14:08:44 +01:00
function analyse_sql_and_script ( & $var , $get )
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 )
{
2010-11-20 14:08:44 +01:00
if ( test_sql_and_script_inject ( $key , $get ) > 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
{
2010-11-20 14:08:44 +01:00
if ( analyse_sql_and_script ( $value , $get ))
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
{
2010-11-20 14:08:44 +01:00
return ( test_sql_and_script_inject ( $var , $get ) <= 0 );
2008-09-30 02:10:49 +02:00
}
2007-01-19 19:25:10 +01:00
}
2010-11-20 14:08:44 +01:00
analyse_sql_and_script ( $_GET , 1 );
analyse_sql_and_script ( $_POST , 0 );
2007-01-19 19:25:10 +01:00
2010-12-15 00:27:17 +01:00
// This is to make Dolibarr working with Plesk
2011-01-26 16:29:45 +01:00
if ( ! empty ( $_SERVER [ 'DOCUMENT_ROOT' ])) set_include_path ( $_SERVER [ 'DOCUMENT_ROOT' ] . '/htdocs' );
2008-01-20 22:53:43 +01:00
2010-12-29 13:13:36 +01:00
// Include the conf.php and functions.lib.php
require_once ( " filefunc.inc.php " );
2009-05-22 00:28:05 +02:00
// Init session. Name of session is specific to Dolibarr instance.
2010-12-29 13:13:36 +01:00
$prefix = dol_getprefix ();
$sessionname = 'DOLSESSID_' . $prefix ;
$sessiontimeout = 'DOLSESSTIMEOUT_' . $prefix ;
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
2010-12-29 13:13:36 +01:00
// Init the 5 global objects
// This include will set: $conf, $db, $langs, $user, $mysoc objects
2005-11-01 00:49:35 +01:00
require_once ( " master.inc.php " );
2008-01-10 18:12:07 +01:00
2010-12-29 13:13:36 +01:00
2010-02-20 12:40:36 +01:00
// Force HTTPS if required ($conf->file->main_force_https is 0/1 or https dolibarr root url)
2010-05-10 06:50:39 +02:00
if ( ! empty ( $conf -> file -> main_force_https ))
2008-04-06 22:17:11 +02:00
{
2010-02-20 12:40:36 +01:00
$newurl = '' ;
if ( $conf -> file -> main_force_https == '1' )
2008-04-06 22:17:11 +02:00
{
2010-02-20 12:40:36 +01:00
if ( ! empty ( $_SERVER [ " SCRIPT_URI " ])) // If SCRIPT_URI supported by server
2008-04-06 22:17:11 +02:00
{
2010-02-20 12:40:36 +01:00
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 " ]);
}
2008-04-06 22:17:11 +02:00
}
2010-02-20 12:40:36 +01:00
else // Check HTTPS environment variable (Apache/mod_ssl only)
2008-04-06 22:17:11 +02:00
{
2010-02-20 12:40:36 +01:00
// $_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 " ];
}
2008-04-06 22:17:11 +02:00
}
}
2010-02-20 12:40:36 +01:00
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 );
}
2008-04-06 22:17:11 +02:00
}
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
2010-04-28 12:02:54 +02:00
if ( ! defined ( 'NOREQUIREMENU' )) require_once ( DOL_DOCUMENT_ROOT . " /core/class/menu.class.php " ); // Need 10ko memory (11ko in 2.2)
2010-05-03 10:22:35 +02:00
if ( ! defined ( 'NOREQUIREHTML' )) require_once ( DOL_DOCUMENT_ROOT . " /core/class/html.form.class.php " ); // Need 660ko memory (800ko in 2.2)
2009-08-28 01:31:50 +02:00
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.
2010-02-15 22:22:04 +01:00
if (( ! empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) && ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE != DOL_VERSION ))
|| ( empty ( $conf -> global -> MAIN_VERSION_LAST_UPGRADE ) && ! empty ( $conf -> global -> MAIN_VERSION_LAST_INSTALL ) && ( $conf -> global -> MAIN_VERSION_LAST_INSTALL != DOL_VERSION )))
2009-08-08 18:26:06 +02:00
{
require_once ( DOL_DOCUMENT_ROOT . " /lib/admin.lib.php " );
2009-10-20 15:14:44 +02:00
$dolibarrversionlastupgrade = preg_split ( '/[.-]/' , $conf -> global -> MAIN_VERSION_LAST_UPGRADE );
$dolibarrversionprogram = preg_split ( '/[.-]/' , DOL_VERSION );
2009-08-08 18:26:06 +02:00
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 ;
}
}
2010-02-19 14:50:49 +01:00
// Creation of a token against CSRF vulnerabilities
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-12-28 02:53:45 +01:00
if ( ! empty ( $conf -> global -> MAIN_SECURITY_CSRF )) // Check validity of token, only if 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)
2010-08-29 20:29:19 +02:00
if ( ! empty ( $_GET [ " disablemodules " ])) $_SESSION [ " disablemodules " ] = $_GET [ " disablemodules " ];
if ( ! empty ( $_POST [ " disablemodules " ])) $_SESSION [ " disablemodules " ] = $_POST [ " disablemodules " ];
2009-01-21 14:06:34 +01:00
if ( ! empty ( $_SESSION [ " disablemodules " ]))
2008-11-28 00:24:50 +01:00
{
2009-10-20 15:14:44 +02:00
$disabled_modules = explode ( ',' , $_SESSION [ " disablemodules " ]);
2008-11-28 00:24:50 +01:00
foreach ( $disabled_modules as $module )
{
2010-09-28 22:40:10 +02:00
if ( $module ) $conf -> $module -> enabled = false ;
2008-11-28 00:24:50 +01:00
}
}
2010-06-02 20:50:46 +02:00
// Init Smarty (used by some modules like multicompany)
2010-08-16 18:33:25 +02:00
if ( sizeof ( $conf -> need_smarty ) > 0 )
2009-12-28 02:53:45 +01:00
{
2010-02-28 15:16:46 +01:00
// Usage of const in conf.php file (deprecated) can overwrite default dir.
2010-06-02 20:42:24 +02:00
$dolibarr_smarty_libs_dir = DOL_DOCUMENT_ROOT . '/includes/smarty/libs/' ;
$dolibarr_smarty_compile = DOL_DATA_ROOT . '/smarty/templates/temp' ;
$dolibarr_smarty_cache = DOL_DATA_ROOT . '/smarty/cache/temp' ;
2010-04-03 16:39:24 +02:00
2010-03-19 12:20:29 +01:00
// Create directory if not exist
if ( ! is_dir ( $dolibarr_smarty_compile )) create_exdir ( $dolibarr_smarty_compile );
if ( ! is_dir ( $dolibarr_smarty_cache )) create_exdir ( $dolibarr_smarty_cache );
2009-12-28 02:53:45 +01:00
$smarty_libs = $dolibarr_smarty_libs_dir . " Smarty.class.php " ;
if ( @ include_once ( $smarty_libs ))
{
$smarty = new Smarty ();
$smarty -> compile_dir = $dolibarr_smarty_compile ;
$smarty -> cache_dir = $dolibarr_smarty_cache ;
}
else
{
dol_print_error ( '' , " Library Smarty " . $smarty_libs . " not found. " );
}
}
2010-09-29 13:08:52 +02:00
// Init Smartphone (for dev only)
if ( $conf -> global -> MAIN_FEATURES_LEVEL == 2 && isset ( $conf -> browser -> phone ))
2010-09-22 08:30:32 +02:00
{
include_once ( DOL_DOCUMENT_ROOT . " /core/class/smartphone.class.php " );
2010-09-28 22:40:10 +02:00
2010-09-22 08:30:32 +02:00
$smartphone = new Smartphone ( $db );
$smartphone -> phone = $conf -> browser -> phone ;
}
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
*/
$login = '' ;
2009-12-29 19:10:48 +01:00
if ( ! defined ( 'NOLOGIN' ))
2005-11-01 18:48:46 +01:00
{
2010-02-19 14:50:49 +01:00
// $authmode lists the different means of identification to be tested in order of preference.
2009-12-29 19:10:48 +01:00
// Example: 'http'
// Example: 'dolibarr'
// Example: 'ldap'
// Example: 'http,forceuser'
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Authentication mode
if ( empty ( $dolibarr_main_authentication )) $dolibarr_main_authentication = 'http,dolibarr' ;
// Authentication mode: forceuser
if ( $dolibarr_main_authentication == 'forceuser' && empty ( $dolibarr_auto_user )) $dolibarr_auto_user = 'auto' ;
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Set authmode
$authmode = explode ( ',' , $dolibarr_main_authentication );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// No authentication mode
2010-08-24 16:18:38 +02:00
if ( ! sizeof ( $authmode ) && empty ( $conf -> login_method_modules ))
2007-12-31 00:49:16 +01:00
{
2009-12-29 19:10:48 +01:00
$langs -> load ( 'main' );
dol_print_error ( '' , $langs -> trans ( " ErrorConfigParameterNotDefined " , 'dolibarr_main_authentication' ));
exit ;
2007-12-31 00:49:16 +01:00
}
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// If requested by the login has already occurred, it is retrieved from the session
// Call module if not realized that his request.
// At the end of this phase, the variable $login is defined.
2009-12-29 19:10:48 +01:00
$resultFetchUser = '' ;
$test = true ;
if ( ! isset ( $_SESSION [ " dol_login " ]))
2006-07-02 02:43:40 +02:00
{
2010-02-19 14:50:49 +01:00
// It is not already authenticated, it requests the login / password
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// Verification security graphic code
2009-12-29 19:10:48 +01:00
if ( $test && isset ( $_POST [ " username " ]) && ! empty ( $conf -> global -> MAIN_SECURITY_ENABLECAPTCHA ))
{
require_once DOL_DOCUMENT_ROOT . '/includes/artichow/Artichow.cfg.php' ;
require_once ARTICHOW . " /AntiSpam.class.php " ;
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// It creates an anti-spam object
2009-12-29 19:10:48 +01:00
$object = new AntiSpam ();
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Verifie code
if ( ! $object -> check ( 'dol_antispam_value' , $_POST [ 'code' ], true ))
{
dol_syslog ( 'Bad value for code, connexion refused' );
$langs -> load ( 'main' );
$langs -> load ( 'other' );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$user -> trigger_mesg = 'ErrorBadValueForCode - login=' . $_POST [ " username " ];
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorBadValueForCode " );
$test = false ;
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Appel des triggers
2010-04-28 12:33:16 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
2009-12-29 19:10:48 +01:00
$interface = new Interfaces ( $db );
2010-04-22 00:14:11 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf , $_POST [ " entity " ]);
2009-12-29 19:10:48 +01:00
if ( $result < 0 ) { $error ++ ; }
// Fin appel triggers
}
}
2010-08-26 04:07:52 +02:00
2010-08-24 13:04:16 +02:00
// Validation of third party module login method
if ( is_array ( $conf -> login_method_modules ) && ! empty ( $conf -> login_method_modules ))
{
$login = getLoginMethod ();
2010-08-24 14:42:14 +02:00
if ( $login ) $test = false ;
2010-08-24 13:04:16 +02:00
}
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// Validation tests user / password
// If ok, the variable will be initialized login
2010-04-13 23:56:06 +02:00
// If error, we will put error message in session under the name dol_loginmesg
2009-12-29 19:10:48 +01:00
$goontestloop = false ;
if ( isset ( $_SERVER [ " REMOTE_USER " ]) && in_array ( 'http' , $authmode )) $goontestloop = true ;
2010-12-01 22:28:08 +01:00
if ( isset ( $_POST [ " username " ]) || GETPOST ( 'openid_mode' , 'alpha' , 1 )) $goontestloop = true ;
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
if ( $test && $goontestloop )
2008-01-02 14:08:27 +01:00
{
2009-12-29 19:10:48 +01:00
foreach ( $authmode as $mode )
2007-12-31 00:49:16 +01:00
{
2009-12-29 19:10:48 +01:00
if ( $test && $mode && ! $login )
2008-04-09 23:38:39 +02:00
{
2009-12-29 19:10:48 +01:00
$authfile = DOL_DOCUMENT_ROOT . '/includes/login/functions_' . $mode . '.php' ;
$result = include_once ( $authfile );
if ( $result )
2008-05-02 03:10:00 +02:00
{
2009-12-29 19:10:48 +01:00
// Call function to check user/password
$usertotest = $_POST [ " username " ];
$passwordtotest = $_POST [ " password " ];
$function = 'check_user_password_' . $mode ;
$login = $function ( $usertotest , $passwordtotest );
2010-12-08 12:45:47 +01:00
if ( $login ) // Login is successfull
2009-12-29 19:10:48 +01:00
{
$test = false ;
2010-12-08 12:45:47 +01:00
$dol_authmode = $mode ; // This properties is defined only when logged to say what mode was successfully used
$dol_tz = $_POST [ " tz " ];
$dol_dst = $_POST [ " dst " ];
$dol_screenwidth = $_POST [ " screenwidth " ];
$dol_screenheight = $_POST [ " screenheight " ];
2009-12-29 19:10:48 +01:00
}
}
else
{
dol_syslog ( " Authentification ko - failed to load file ' " . $authfile . " ' " , LOG_ERR );
sleep ( 1 );
$langs -> load ( 'main' );
$langs -> load ( 'other' );
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorFailedToLoadLoginFileForMode " , $mode );
2008-05-02 03:10:00 +02:00
}
2008-04-09 23:38:39 +02:00
}
2008-01-04 19:35:17 +01:00
}
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
if ( ! $login )
{
dol_syslog ( 'Bad password, connexion refused' , LOG_DEBUG );
$langs -> load ( 'main' );
$langs -> load ( 'other' );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Bad password. No authmode has found a good password.
$user -> trigger_mesg = $langs -> trans ( " ErrorBadLoginPassword " ) . ' - login=' . $_POST [ " username " ];
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorBadLoginPassword " );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Appel des triggers
2010-04-28 12:33:16 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
2009-12-29 19:10:48 +01:00
$interface = new Interfaces ( $db );
2010-04-22 00:14:11 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf , $_POST [ " entity " ]);
2009-12-29 19:10:48 +01:00
if ( $result < 0 ) { $error ++ ; }
// Fin appel triggers
}
2008-01-04 19:35:17 +01:00
}
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// End test login / passwords
2008-04-09 23:38:39 +02:00
if ( ! $login )
{
2009-12-29 19:10:48 +01:00
// We show login page
include_once ( DOL_DOCUMENT_ROOT . " /lib/security.lib.php " );
2010-07-27 01:50:09 +02:00
if ( ! is_object ( $langs )) // This can occurs when calling page with NOREQUIRETRAN defined
{
include_once ( DOL_DOCUMENT_ROOT . " /core/class/translate.class.php " );
$langs = new Translate ( " " , $conf );
}
2010-01-11 00:54:42 +01:00
dol_loginfunction ( $langs , $conf , $mysoc );
2009-12-29 19:10:48 +01:00
exit ;
}
2010-01-11 00:54:42 +01:00
2010-04-28 09:31:34 +02:00
$resultFetchUser = $user -> fetch ( '' , $login );
2009-12-29 19:10:48 +01:00
if ( $resultFetchUser <= 0 )
{
dol_syslog ( 'User not found, connexion refused' );
session_destroy ();
session_name ( $sessionname );
session_start ();
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
if ( $resultFetchUser == 0 )
{
$langs -> load ( 'main' );
$langs -> load ( 'other' );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$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 ;
}
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// Call triggers
2010-04-28 12:33:16 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
2008-04-09 23:38:39 +02:00
$interface = new Interfaces ( $db );
2010-04-22 00:14:11 +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 ++ ; }
2010-02-19 14:50:49 +01:00
// End call triggers
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
header ( 'Location: ' . DOL_URL_ROOT . '/index.php' );
exit ;
2008-04-09 23:38:39 +02:00
}
}
2009-12-29 19:10:48 +01:00
else
2008-09-30 02:10:49 +02:00
{
2010-12-08 12:45:47 +01:00
// We are already into an authenticated session
2009-12-29 19:10:48 +01:00
$login = $_SESSION [ " dol_login " ];
dol_syslog ( " This is an already logged session. _SESSION['dol_login']= " . $login );
2010-01-11 00:54:42 +01:00
2010-12-08 12:45:47 +01:00
$resultFetchUser = $user -> fetch ( '' , $login );
2009-12-29 19:10:48 +01:00
if ( $resultFetchUser <= 0 )
2009-12-27 06:50:46 +01:00
{
2009-12-29 19:10:48 +01:00
// Account has been removed after login
dol_syslog ( " Can't load user even if session logged. _SESSION['dol_login']= " . $login , LOG_WARNING );
session_destroy ();
session_name ( $sessionname );
session_start ();
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
if ( $resultFetchUser == 0 )
{
$langs -> load ( 'main' );
$langs -> load ( 'other' );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$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 ;
}
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// Call triggers
2010-04-28 12:33:16 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
2009-12-29 19:10:48 +01:00
$interface = new Interfaces ( $db );
2010-04-22 00:14:11 +02:00
$result = $interface -> run_triggers ( 'USER_LOGIN_FAILED' , $user , $user , $langs , $conf ,( isset ( $_POST [ " entity " ]) ? $_POST [ " entity " ] : 0 ));
2009-12-29 19:10:48 +01:00
if ( $result < 0 ) { $error ++ ; }
2010-02-19 14:50:49 +01:00
// End call triggers
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
header ( 'Location: ' . DOL_URL_ROOT . '/index.php' );
exit ;
2009-12-27 06:50:46 +01:00
}
2010-08-24 14:42:14 +02:00
else
{
2010-12-08 12:45:47 +01:00
if ( ! empty ( $conf -> MAIN_ACTIVATE_UPDATESESSIONTRIGGER )) // We do not execute such trigger at each page load by default
2010-09-15 00:14:55 +02:00
{
// Call triggers
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
$interface = new Interfaces ( $db );
$result = $interface -> run_triggers ( 'USER_UPDATE_SESSION' , $user , $user , $langs , $conf , $conf -> entity );
if ( $result < 0 ) { $error ++ ; }
// End call triggers
}
2010-08-24 14:42:14 +02:00
}
2008-09-30 02:10:49 +02:00
}
2010-01-11 00:54:42 +01:00
2010-12-08 12:45:47 +01:00
// Is it a new session that has started ?
// If we are here this means authentication was successfull.
2009-12-29 19:10:48 +01:00
if ( ! isset ( $_SESSION [ " dol_login " ]))
2006-12-09 03:23:07 +01:00
{
2009-12-29 19:10:48 +01:00
$error = 0 ;
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// New session for this login
$_SESSION [ " dol_login " ] = $user -> login ;
2010-12-08 12:45:47 +01:00
$_SESSION [ " dol_authmode " ] = isset ( $dol_authmode ) ? $dol_authmode : '' ;
$_SESSION [ " dol_tz " ] = isset ( $dol_tz ) ? $dol_tz : '' ;
$_SESSION [ " dol_dst " ] = isset ( $dol_dst ) ? $dol_dst : '' ;
$_SESSION [ " dol_screenwidth " ] = isset ( $dol_screenwidth ) ? $dol_screenwidth : '' ;
$_SESSION [ " dol_screenheight " ] = isset ( $dol_screenheight ) ? $dol_screenheight : '' ;
2009-12-29 19:10:48 +01:00
$_SESSION [ " dol_company " ] = $conf -> global -> MAIN_INFO_SOCIETE_NOM ;
if ( $conf -> multicompany -> enabled ) $_SESSION [ " dol_entity " ] = $conf -> entity ;
dol_syslog ( " This is a new started user session. _SESSION['dol_login']= " . $_SESSION [ " dol_login " ] . ' Session id=' . session_id ());
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$db -> begin ();
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$user -> update_last_login_date ();
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// Call triggers
2010-04-28 12:33:16 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/interfaces.class.php " );
2008-04-09 23:38:39 +02:00
$interface = new Interfaces ( $db );
2010-04-22 00:14:11 +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 ++ ; }
2010-02-19 14:50:49 +01:00
// End call triggers
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
if ( $error )
2008-04-09 23:38:39 +02:00
{
2009-12-29 19:10:48 +01:00
$db -> rollback ();
session_destroy ();
dol_print_error ( $db , 'Error in some triggers on action USER_LOGIN' , LOG_ERR );
exit ;
2008-04-09 23:38:39 +02:00
}
2009-12-29 19:10:48 +01:00
else
2008-04-09 23:38:39 +02:00
{
2009-12-29 19:10:48 +01:00
$db -> commit ();
}
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01: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 " ]))
{
2010-04-28 12:02:54 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /core/class/cookie.class.php " );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$entity = $_SESSION [ " dol_login " ] . '|' . $_POST [ " entity " ];
2010-12-27 20:13:06 +01:00
$prefix = dol_getprefix ();
$entityCookieName = 'DOLENTITYID_' . $prefix ;
2010-02-19 14:50:49 +01:00
// TTL : is defined in the config page multicompany
2009-12-29 19:10:48 +01:00
$ttl = ( ! empty ( $conf -> global -> MAIN_MULTICOMPANY_COOKIE_TTL ) ? $conf -> global -> MAIN_MULTICOMPANY_COOKIE_TTL : time () + 60 * 60 * 8 );
2010-02-19 14:50:49 +01:00
// Cryptkey : will be created randomly in the config page multicompany
2009-12-29 19:10:48 +01:00
$cryptkey = ( ! empty ( $conf -> file -> cookie_cryptkey ) ? $conf -> file -> cookie_cryptkey : '' );
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
$entityCookie = new DolCookie ( $cryptkey );
$entityCookie -> _setCookie ( $entityCookieName , $entity , $ttl );
}
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Module webcalendar
if ( ! empty ( $conf -> webcal -> enabled ) && $user -> webcal_login != " " )
{
$domain = '' ;
2010-01-11 00:54:42 +01:00
2010-02-19 14:50:49 +01:00
// Creation of a cookie to save login
2009-12-29 19:10:48 +01:00
$cookiename = 'webcalendar_login' ;
if ( ! isset ( $_COOKIE [ $cookiename ]))
{
setcookie ( $cookiename , $user -> webcal_login , 0 , " / " , $domain , 0 );
}
2010-02-19 14:50:49 +01:00
// Creation of a cookie to save session
2009-12-29 19:10:48 +01:00
$cookiename = 'webcalendar_session' ;
if ( ! isset ( $_COOKIE [ $cookiename ]))
{
setcookie ( $cookiename , 'TODO' , 0 , " / " , $domain , 0 );
}
}
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Module Phenix
if ( ! empty ( $conf -> phenix -> enabled ) && $user -> phenix_login != " " && $conf -> phenix -> cookie )
{
// Creation du cookie permettant la connexion automatique, valide jusqu'a la fermeture du browser
if ( ! isset ( $_COOKIE [ $conf -> phenix -> cookie ]))
{
setcookie ( $conf -> phenix -> cookie , $user -> phenix_login . " : " . $user -> phenix_pass_crypted . " :1 " , 0 , " / " , " " , 0 );
}
2008-04-09 23:38:39 +02:00
}
2007-12-31 00:49:16 +01:00
}
2010-01-11 00:54:42 +01:00
2008-09-30 02:10:49 +02:00
2010-02-19 14:50:49 +01:00
// If user admin, we force the rights-based modules
2009-12-29 19:10:48 +01:00
if ( $user -> admin )
2008-03-17 15:59:34 +01:00
{
2009-12-29 19:10:48 +01: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 ;
2008-03-17 15:59:34 +01:00
}
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
/*
2010-12-08 12:45:47 +01:00
* Overwrite configs global by peronal configs
2009-12-29 19:10:48 +01:00
*/
// Set liste_limit
if ( isset ( $user -> conf -> MAIN_SIZE_LISTE_LIMIT )) // Can be 0
2008-03-17 15:59:34 +01:00
{
2009-12-29 19:10:48 +01:00
$conf -> liste_limit = $user -> conf -> MAIN_SIZE_LISTE_LIMIT ;
2008-03-17 15:59:34 +01:00
}
2009-12-29 19:10:48 +01:00
if ( isset ( $user -> conf -> PRODUIT_LIMIT_SIZE )) // Can be 0
2009-04-23 15:19:28 +02:00
{
2010-06-02 10:34:44 +02:00
$conf -> product -> limit_size = $user -> conf -> PRODUIT_LIMIT_SIZE ;
2009-04-23 15:19:28 +02:00
}
2009-12-29 19:10:48 +01:00
// Replace conf->css by personalized value
if ( isset ( $user -> conf -> MAIN_THEME ) && $user -> conf -> MAIN_THEME )
2007-11-12 23:40:23 +01:00
{
2009-12-29 19:10:48 +01:00
$conf -> theme = $user -> conf -> MAIN_THEME ;
2010-06-25 21:52:11 +02:00
$conf -> css = " /theme/ " . $conf -> theme . " /style.css.php " ;
2007-11-12 23:40:23 +01:00
}
2009-12-29 19:10:48 +01:00
// Set javascript option
2010-08-27 23:02:31 +02:00
if ( empty ( $_GET [ " nojs " ])) // If javascript was not disabled on URL
{
if ( ! empty ( $user -> conf -> MAIN_DISABLE_JAVASCRIPT ))
{
$conf -> use_javascript_ajax =! $user -> conf -> MAIN_DISABLE_JAVASCRIPT ;
}
}
else $conf -> use_javascript_ajax = 0 ;
2007-10-02 15:54:34 +02:00
}
2006-07-02 02:43:40 +02:00
2008-07-15 20:09:22 +02:00
2010-02-28 15:49:39 +01:00
if ( ! defined ( 'NOREQUIRETRAN' ))
2005-08-11 22:04:33 +02:00
{
2010-02-28 15:49:39 +01:00
if ( empty ( $_GET [ " lang " ])) // If language was not forced on URL
2008-09-30 02:10:49 +02:00
{
2010-02-28 15:49:39 +01:00
// If user has chosen its own language
if ( ! empty ( $user -> conf -> MAIN_LANG_DEFAULT ))
2009-05-08 17:40:33 +02:00
{
2010-02-28 15:49:39 +01: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 );
}
2009-05-08 17:40:33 +02:00
}
2008-09-30 02:10:49 +02:00
}
2010-02-28 15:49:39 +01:00
else // If language was forced on URL
{
$langs -> setDefaultLang ( $_GET [ " lang " ]);
}
2005-08-11 22:04:33 +02:00
}
2005-10-02 22:38:46 +02:00
2010-02-19 14:50:49 +01:00
// Case forcing style from 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 " ];
2010-06-25 21:52:11 +02:00
$conf -> css = " /theme/ " . $conf -> theme . " /style.css.php " ;
2007-08-02 21:07:50 +02:00
}
2005-10-02 22:38:46 +02:00
2009-12-17 16:44:51 +01:00
// Define menu manager to use
2010-02-19 14:50:49 +01:00
if ( empty ( $user -> societe_id )) // If internal user or not defined
2005-09-26 02:52:33 +02:00
{
2011-02-13 16:50:42 +01:00
$conf -> top_menu = ( empty ( $conf -> global -> MAIN_MENU_STANDARD_FORCED ) ? $conf -> global -> MAIN_MENU_STANDARD : $conf -> global -> MAIN_MENU_STANDARD_FORCED );
$conf -> smart_menu = ( empty ( $conf -> global -> MAIN_MENU_SMARTPHONE_FORCED ) ? $conf -> global -> MAIN_MENU_SMARTPHONE : $conf -> global -> MAIN_MENU_SMARTPHONE_FORCED );
2010-02-28 15:16:46 +01:00
// For backward compatibility
2010-09-29 12:10:33 +02:00
if ( $conf -> top_menu == 'eldy.php' ) $conf -> top_menu = 'eldy_backoffice.php' ;
2010-02-28 15:16:46 +01:00
if ( $conf -> top_menu == 'rodolphe.php' ) $conf -> top_menu = 'eldy_backoffice.php' ;
2005-09-26 02:52:33 +02:00
}
2010-02-19 14:50:49 +01:00
else // If external user
2005-09-26 02:52:33 +02:00
{
2011-02-13 16:50:42 +01:00
$conf -> top_menu = ( empty ( $conf -> global -> MAIN_MENUFRONT_STANDARD_FORCED ) ? $conf -> global -> MAIN_MENUFRONT_STANDARD : $conf -> global -> MAIN_MENUFRONT_STANDARD_FORCED );
$conf -> smart_menu = ( empty ( $conf -> global -> MAIN_MENUFRONT_SMARTPHONE_FORCED ) ? $conf -> global -> MAIN_MENUFRONT_SMARTPHONE : $conf -> global -> MAIN_MENUFRONT_SMARTPHONE_FORCED );
2010-02-28 15:16:46 +01:00
// For backward compatibility
2010-09-29 13:08:52 +02:00
if ( $conf -> top_menu == 'eldy.php' ) $conf -> top_menu = 'eldy_frontoffice.php' ;
2010-02-28 15:16:46 +01:00
if ( $conf -> top_menu == 'rodolphe.php' ) $conf -> top_menu = 'eldy_frontoffice.php' ;
2005-09-26 02:52:33 +02:00
}
2005-08-11 22:04:33 +02:00
2009-12-29 19:10:48 +01:00
if ( ! defined ( 'NOLOGIN' ))
{
2010-02-19 14:50:49 +01:00
// If the login is not recovered, it is identified with an account that does not exist.
// Hacking attempt?
2009-12-29 19:10:48 +01:00
if ( ! $user -> login ) accessforbidden ();
2010-01-11 00:54:42 +01:00
2009-12-29 19:10:48 +01:00
// Check if user is active
if ( $user -> statut < 1 )
2007-10-07 16:49:36 +02:00
{
2010-02-19 14:50:49 +01:00
// If not active, we refuse the user
2009-12-29 19:10:48 +01:00
$langs -> load ( " other " );
dol_syslog ( " Authentification ko as login is disabled " );
accessforbidden ( $langs -> trans ( " ErrorLoginDisabled " ));
exit ;
2007-10-07 16:49:36 +02:00
}
2009-12-29 19:10:48 +01:00
// Load permissions
$user -> getrights ();
2006-09-02 03:17:50 +02:00
}
2009-01-21 14:06:34 +01:00
2010-07-14 16:25:48 +02:00
dol_syslog ( " --- Access to " . $_SERVER [ " PHP_SELF " ]);
2009-08-29 00:46:40 +02:00
//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
2010-02-28 15:16:46 +01:00
// Load main languages files
if ( ! defined ( 'NOREQUIRETRAN' ))
{
$langs -> load ( " main " );
$langs -> load ( " dict " );
}
2003-03-11 17:25:07 +01:00
2008-04-09 20:13:45 +02:00
// Define some constants used for style of arrays
2010-08-29 19:43:51 +02:00
$bc = array ( 0 => 'class="impair"' , 1 => 'class="pair"' );
2010-10-02 22:47:55 +02:00
$bcdd = array ( 0 => 'class="impair drag drop"' , 1 => 'class="pair drag drop"' );
2010-09-14 09:05:31 +02:00
$bcnd = array ( 0 => 'class="impair nodrag nodrop"' , 1 => 'class="pair nodrag nodrop"' );
2003-09-06 14:41:17 +02:00
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
}
2010-04-03 17:08:09 +02:00
$heightforframes = 48 ;
// Functions
2004-02-21 01:15:04 +01:00
2010-02-28 05:32:18 +01:00
/**
2011-01-19 11:37:59 +01:00
* Show HTML header HTML + BODY + Top menu + left menu + DIV
* @ param head Add optionnal head lines
* @ param title Title of web page
* @ param help_url Url links to help page
* @ param target Target to use in menu links
* @ param disablejs Do not output links to js ( Ex : qd fonction utilisee par sous formulaire Ajax )
* @ 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
* @ param morequerystring Query string to add to the link " print " to get same parameters ( use only if autodetect fails )
2010-02-28 05:32:18 +01:00
*/
if ( ! function_exists ( " llxHeader " ))
{
2011-01-19 11:37:59 +01:00
function llxHeader ( $head = '' , $title = '' , $help_url = '' , $target = '' , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' , $morequerystring = '' )
2010-02-28 05:32:18 +01:00
{
2010-04-03 17:08:09 +02:00
top_htmlhead ( $head , $title , $disablejs , $disablehead , $arrayofjs , $arrayofcss ); // Show html headers
2011-01-19 11:37:59 +01:00
top_menu ( $head , $title , $target , $disablejs , $disablehead , $arrayofjs , $arrayofcss , $morequerystring );
2010-11-02 13:03:29 +01:00
left_menu ( '' , $help_url , '' , '' , 1 );
2010-10-29 19:54:15 +02:00
main_area ();
2010-02-28 05:32:18 +01:00
}
}
2010-08-30 20:31:59 +02:00
/**
* Show HTML header
*/
function top_httphead ()
{
global $conf ;
//header("Content-type: text/html; charset=UTF-8");
header ( " Content-type: text/html; charset= " . $conf -> file -> character_set_client );
// On the fly GZIP compression for all pages (if browser support it). Must set the bit 3 of constant to 1.
if ( isset ( $conf -> global -> MAIN_OPTIMIZE_SPEED ) && ( $conf -> global -> MAIN_OPTIMIZE_SPEED & 0x04 )) { ob_start ( " ob_gzhandler " ); }
}
2005-01-01 20:48:22 +01:00
/**
2010-10-22 04:00:50 +02:00
* Show HTML header
* @ param head Optionnal head lines
* @ param title Web page title
* @ param disablejs Do not output links to js ( Ex : qd fonction utilisee par sous formulaire Ajax )
* @ 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
2010-08-30 20:31:59 +02:00
top_httphead ();
2009-08-19 18:26:12 +02:00
2010-08-30 20:31:59 +02:00
if ( empty ( $conf -> css )) $conf -> css = '/theme/eldy/style.css.php' ; // If not defined, eldy by default
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 " ;
2010-04-06 23:56:03 +02:00
if ( empty ( $disablehead ))
2007-05-26 18:52:29 +02:00
{
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
2010-02-19 14:50:49 +01:00
// Displays meta
2007-09-15 16:35:44 +02:00
print '<meta name="robots" content="noindex,nofollow">' . " \n " ; // Evite indexation par robots
print '<meta name="author" content="Dolibarr Development Team">' . " \n " ;
2010-03-17 22:41:06 +01:00
print '<link rel="shortcut icon" type="image/x-icon" href="' . DOL_URL_ROOT . '/favicon.ico">' . " \n " ;
2003-10-21 11:40:34 +02:00
2010-02-19 14:50:49 +01:00
// Displays 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
2010-08-22 20:02:32 +02:00
if ( ! defined ( 'DISABLE_JQUERY' ))
{
print '<!-- Includes for JQuery (Ajax library) -->' . " \n " ;
2010-10-11 14:06:43 +02:00
$jquerytheme = 'smoothness' ;
if ( ! empty ( $conf -> global -> MAIN_USE_JQUERY_THEME )) $jquerytheme = $conf -> global -> MAIN_USE_JQUERY_THEME ;
2010-12-11 12:45:30 +01:00
print '<link rel="stylesheet" href="' . DOL_URL_ROOT . '/includes/jquery/css/' . $jquerytheme . '/jquery-ui-latest.custom.css" type="text/css" />' . " \n " ;
2010-10-22 10:06:41 +02:00
print '<link rel="stylesheet" href="' . DOL_URL_ROOT . '/includes/jquery/plugins/tooltip/jquery.tooltip.css" type="text/css" />' . " \n " ;
2010-08-22 20:02:32 +02:00
}
print '<!-- Includes for Dolibarr, modules or specific pages-->' . " \n " ;
// Output style sheets (optioncss='print' or '')
2010-08-26 04:07:52 +02:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . DOL_URL_ROOT . $conf -> css . '?lang=' . $langs -> defaultlang . '&theme=' . $conf -> theme . ( ! empty ( $_GET [ " optioncss " ]) ? '&optioncss=' . $_GET [ " optioncss " ] : '' ) . '">' . " \n " ;
2010-01-13 14:11:32 +01:00
// CSS forced by modules (relative url starting with /)
2008-03-31 00:25:39 +02:00
if ( is_array ( $conf -> css_modules ))
{
foreach ( $conf -> css_modules as $cssfile )
{ // cssfile is an absolute path
2010-12-19 19:43:44 +01:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . dol_buildpath ( $cssfile , 1 ) . '?lang=' . $langs -> defaultlang . '&theme=' . $conf -> theme . ( ! empty ( $_GET [ " optioncss " ]) ? '&optioncss=' . $_GET [ " optioncss " ] : '' ) . '">' . " \n " ;
2008-03-31 00:25:39 +02:00
}
}
2010-01-13 14:11:32 +01:00
// CSS forced by page in top_htmlhead call (relative url starting with /)
2008-02-11 16:51:03 +01:00
if ( is_array ( $arrayofcss ))
{
foreach ( $arrayofcss as $cssfile )
{
2011-01-06 21:29:14 +01:00
print '<link rel="stylesheet" type="text/css" title="default" href="' . dol_buildpath ( $cssfile , 1 ) . '?lang=' . $langs -> defaultlang . '&theme=' . $conf -> theme . ( ! empty ( $_GET [ " optioncss " ]) ? '&optioncss=' . $_GET [ " optioncss " ] : '' ) . '">' . " \n " ;
2008-02-11 16:51:03 +01:00
}
}
2010-03-16 02:18:25 +01: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
{
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' ;
2010-02-02 09:07:30 +01:00
if ( isset ( $conf -> global -> MAIN_OPTIMIZE_SPEED ) && ( $conf -> global -> MAIN_OPTIMIZE_SPEED & 0x01 )) { $mini = '_mini' ; $ext = '.jgz' ; } // mini='_mini', ext='.gz'
2008-01-26 21:22:40 +01:00
2010-11-10 20:18:06 +01:00
// JQuery. Must be before other includes (prototype/scriptaculous/...)
2011-02-05 04:34:25 +01:00
print '<!-- Includes JS for JQuery -->' . " \n " ;
2010-12-11 12:45:30 +01:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/js/jquery-latest.min' . $ext . '"></script>' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/js/jquery-ui-latest.custom.min' . $ext . '"></script>' . " \n " ;
2010-10-18 18:11:32 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/tablednd/jquery.tablednd_0_5' . $ext . '"></script>' . " \n " ;
2010-10-22 01:22:32 +02:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/tooltip/jquery.tooltip.min' . $ext . '"></script>' . " \n " ;
2011-02-02 08:59:32 +01:00
// jQuery Layout
2010-11-02 10:10:43 +01:00
if ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT || defined ( 'REQUIRE_JQUERY_LAYOUT' ))
2010-10-30 09:54:26 +02:00
{
2011-02-05 10:26:33 +01:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/jquery/plugins/layout/jquery.layout-latest.min' . $ext . '"></script>' . " \n " ;
2010-10-30 09:54:26 +02:00
}
2011-02-01 19:37:16 +01:00
// CKEditor
if ( ! empty ( $conf -> global -> FCKEDITOR_EDITORNAME ) && $conf -> global -> FCKEDITOR_EDITORNAME == 'ckeditor' )
{
2011-02-05 04:34:25 +01:00
print '<!-- Includes JS for CKEditor -->' . " \n " ;
2011-02-05 11:08:31 +01:00
print '<script type="text/javascript">var CKEDITOR_BASEPATH = \'' . DOL_URL_ROOT . '/includes/ckeditor/\';</script>' . " \n " ;
2011-02-02 08:59:32 +01:00
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/includes/ckeditor/ckeditor' . $ext . '"></script>' . " \n " ;
2011-02-01 19:37:16 +01:00
}
2011-02-05 04:34:25 +01:00
// Global js function
print '<!-- Includes JS of Dolibarr -->' . " \n " ;
print '<script type="text/javascript" src="' . DOL_URL_ROOT . '/lib/lib_head.js"></script>' . " \n " ;
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 ))
{
2011-02-05 04:34:25 +01:00
print '<!-- Includes JS specific to page -->' . " \n " ;
2008-02-11 16:51:03 +01:00
foreach ( $arrayofjs as $jsfile )
{
2010-05-22 13:27:29 +02:00
if ( ! preg_match ( '/^\//' , $jsfile )) $jsfile = '/' . $jsfile ; // For backward compatibility
2011-01-06 21:29:14 +01:00
print '<script type="text/javascript" src="' . dol_buildpath ( $jsfile , 1 ) . '"></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 " ;
2010-05-26 13:22:10 +02:00
if ( ! empty ( $head )) print $head . " \n " ;
2009-10-16 19:24:18 +02:00
if ( ! empty ( $conf -> global -> MAIN_HTML_HEADER )) print $conf -> global -> MAIN_HTML_HEADER . " \n " ;
2009-10-16 19:15:32 +02:00
2009-08-22 18:07:46 +02:00
print " </head> \n \n " ;
2007-09-15 16:35:44 +02:00
}
2010-04-06 23:56:03 +02:00
$conf -> headerdone = 1 ; // To tell header was output
2005-08-20 18:43:30 +02:00
}
2006-09-10 20:07:09 +02:00
2004-08-21 14:18:03 +02:00
2010-04-05 20:41:34 +02:00
/**
2011-01-19 11:37:59 +01:00
* Show an HTML header + a BODY + The top menu bar
* @ param head Lines in the HEAD
* @ param title Title of web page
* @ param target Target to use in menu links
* @ param disablejs Do not output links to js ( Ex : qd fonction utilisee par sous formulaire Ajax )
* @ 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
* @ param morequerystring Query string to add to the link " print " to get same parameters ( use only if autodetect fails )
2010-04-05 20:41:34 +02:00
*/
2011-01-19 11:37:59 +01:00
function top_menu ( $head , $title = '' , $target = '' , $disablejs = 0 , $disablehead = 0 , $arrayofjs = '' , $arrayofcss = '' , $morequerystring = '' )
2010-04-05 20:41:34 +02:00
{
global $user , $conf , $langs , $db , $dolibarr_main_authentication ;
2010-06-27 15:19:38 +02:00
$html = new Form ( $db );
2010-04-05 20:41:34 +02:00
if ( ! $conf -> top_menu ) $conf -> top_menu = 'eldy_backoffice.php' ;
2010-04-06 23:56:03 +02:00
// For backward compatibility with old modules
if ( empty ( $conf -> headerdone )) top_htmlhead ( $head , $title , $disablejs , $disablehead , $arrayofjs , $arrayofcss );
2010-11-02 13:14:06 +01:00
2010-10-30 11:16:11 +02:00
print '<body id="mainbody">' ;
2010-11-02 13:14:06 +01:00
2010-10-30 11:16:11 +02:00
if ( $conf -> use_javascript_ajax )
2010-10-30 09:54:26 +02:00
{
2010-10-30 11:16:11 +02:00
if ( $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )
{
print ' < script type = " text/javascript " >
2010-10-30 09:54:26 +02:00
jQuery ( document ) . ready ( function () {
jQuery ( " body " ) . layout ( layoutSettings );
});
var layoutSettings = {
2010-11-04 08:13:17 +01:00
name : " mainlayout " ,
2010-10-30 09:54:26 +02:00
defaults : {
2010-10-30 10:40:53 +02:00
useStateCookie : true ,
2010-10-30 09:54:26 +02:00
size : " auto " ,
2010-10-30 12:11:48 +02:00
resizable : false ,
2010-10-31 10:05:56 +01:00
//paneClass: "none",
2010-10-30 09:54:26 +02:00
//resizerClass: "resizer",
//togglerClass: "toggler",
2010-10-30 10:32:16 +02:00
//buttonClass: "button",
//contentSelector: ".content",
//contentIgnoreSelector: "span",
2010-10-30 09:54:26 +02:00
togglerTip_open : " Close This Pane " ,
togglerTip_closed : " Open This Pane " ,
2010-10-30 12:26:56 +02:00
resizerTip : " Resize This Pane "
},
west : {
2010-10-31 10:05:56 +01:00
paneClass : " leftContent " ,
2010-10-30 12:26:56 +02:00
spacing_closed : 14 ,
togglerLength_closed : 14 ,
togglerAlign_closed : " top " ,
//togglerLength_open: 0,
2010-10-30 09:54:26 +02:00
// effect defaults - overridden on some panes
2010-10-30 12:26:56 +02:00
//slideTrigger_open: "mouseover",
2010-11-04 08:13:17 +01:00
//initClosed: true,
2010-10-30 12:26:56 +02:00
fxName : " drop " ,
fxSpeed : " normal " ,
fxSettings : { easing : " " }
2010-10-30 09:54:26 +02:00
},
north : {
paneClass : " none " ,
resizerClass : " none " ,
togglerClass : " none " ,
2010-10-30 10:32:16 +02:00
spacing_open : 0 ,
2010-10-30 09:54:26 +02:00
togglerLength_open : 0 ,
togglerLength_closed : - 1 ,
slidable : false ,
fxName : " none "
},
center : {
paneSelector : " #mainContent "
}
}
</ script > ' ;
2010-10-30 11:16:11 +02:00
}
2010-11-02 13:14:06 +01:00
2010-11-01 10:49:34 +01:00
if ( $conf -> global -> MAIN_MENU_USE_JQUERY_ACCORDION )
{
print " \n " . ' < script type = " text/javascript " >
jQuery ( document ) . ready ( function () {
jQuery ( " .vmenu " ) . accordion ({
autoHeight : false ,
event : " mouseover " ,
2010-11-01 12:12:26 +01:00
//collapsible: true,
//active: 2,
2010-11-01 10:49:34 +01:00
header : " > .blockvmenupair > .menu_titre "
});
});
</ script > ' ;
}
2010-10-22 21:18:45 +02:00
2010-10-30 11:16:11 +02:00
// Wrapper to show tooltips
2010-11-01 10:49:34 +01:00
print " \n " . ' < script type = " text/javascript " >
2010-10-22 21:18:45 +02:00
jQuery ( function () {
jQuery ( " .classfortooltip " ) . tooltip ({
track : true ,
delay : 0 ,
showURL : false ,
2010-10-30 11:16:11 +02:00
//extraClass: "pretty fancy",
//fixPNG: true,
2010-10-23 17:45:55 +02:00
positionLeft : false ,
2010-10-22 21:18:45 +02:00
bodyHandler : function () {
2010-10-30 11:16:11 +02:00
//console.log(jQuery(this).attr("tooltipText"));
2010-10-22 21:18:45 +02:00
return jQuery ( this ) . attr ( " tooltipText " ); }
});
});
2010-10-30 11:16:11 +02:00
</ script > ' ;
}
2010-04-05 20:41:34 +02:00
/*
* Top menu
*/
2010-09-03 23:39:37 +02:00
$top_menu = $conf -> top_menu ;
2010-11-11 00:18:23 +01:00
if ( GETPOST ( 'menu' )) $top_menu = GETPOST ( 'menu' ); // menu=eldy_backoffice.php
2010-09-03 23:34:07 +02:00
2010-04-05 20:41:34 +02:00
// Load the top menu manager
2011-01-23 16:08:21 +01:00
$result = dol_include_once ( " /includes/menus/standard/ " . $top_menu );
2010-04-05 20:41:34 +02:00
if ( ! $result ) // If failed to include, we try with standard
{
2010-09-29 12:10:33 +02:00
$top_menu = 'eldy_backoffice.php' ;
2011-01-23 16:08:21 +01:00
include_once ( DOL_DOCUMENT_ROOT . " /includes/menus/standard/ " . $top_menu );
2010-04-05 20:41:34 +02:00
}
2011-02-13 16:50:42 +01:00
2010-09-29 13:57:09 +02:00
print " \n " . '<!-- Start top horizontal menu ' . $top_menu . ' -->' . " \n " ;
2010-11-02 13:14:06 +01:00
2010-11-02 13:03:29 +01:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) print '<div class="ui-layout-north"> <!-- Begin top layout -->' . " \n " ;
2010-10-22 21:18:45 +02:00
2010-10-22 10:06:41 +02:00
print '<div id="tmenu_tooltip" class="tmenu">' . " \n " ;
2010-09-29 13:57:09 +02:00
// Show menu
$menutop = new MenuTop ( $db );
$menutop -> atarget = $target ;
2010-04-05 20:41:34 +02:00
$menutop -> showmenu ();
2011-01-23 16:08:21 +01:00
2011-01-10 09:13:31 +01:00
print " \n </div> \n " ;
2010-04-05 20:41:34 +02:00
// Link to login card
2010-06-27 15:19:38 +02:00
$loginhtmltext = '' ; $logintext = '' ;
2010-11-05 18:47:41 +01:00
if ( $user -> societe_id )
{
$thirdpartystatic = new Societe ( $db );
$thirdpartystatic -> fetch ( $user -> societe_id );
$companylink = ' (' . $thirdpartystatic -> getNomUrl ( '' , '' ) . ')' ;
$company = ' (' . $langs -> trans ( " Company " ) . ': ' . $thirdpartystatic -> name . ')' ;
}
$logintext = '<div class="login"><a href="' . DOL_URL_ROOT . '/user/fiche.php?id=' . $user -> id . '"' ;
2010-06-27 15:19:38 +02:00
$logintext .= $menutop -> atarget ? ( ' target="' . $menutop -> atarget . '"' ) : '' ;
$logintext .= '>' . $user -> login . '</a>' ;
2010-11-05 18:47:41 +01:00
if ( $user -> societe_id ) $logintext .= $companylink ;
$logintext .= '</div>' ;
2010-06-27 15:19:38 +02:00
$loginhtmltext .= '<u>' . $langs -> trans ( " User " ) . '</u>' ;
2010-07-18 12:39:07 +02:00
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Name " ) . '</b>: ' . $user -> getFullName ( $langs );
2010-06-27 15:19:38 +02:00
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Login " ) . '</b>: ' . $user -> login ;
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Administrator " ) . '</b>: ' . yn ( $user -> admin );
2010-11-05 18:47:41 +01:00
$type = ( $user -> societe_id ? $langs -> trans ( " External " ) . $company : $langs -> trans ( " Internal " ));
2010-06-27 15:19:38 +02:00
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Type " ) . '</b>: ' . $type ;
2011-02-06 13:54:00 +01:00
$loginhtmltext .= '<br><b>' . $langs -> trans ( " IPAddress " ) . '</b>: ' . $_SERVER [ " REMOTE_ADDR " ];
2010-06-27 15:19:38 +02:00
$loginhtmltext .= '<br>' ;
$loginhtmltext .= '<br><u>' . $langs -> trans ( " Connection " ) . '</u>' ;
if ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ) $loginhtmltext .= '<br><b>' . $langs -> trans ( " ConnectedOnMultiCompany " ) . '</b>: ' . $conf -> entity . ' (user entity ' . $user -> entity . ')' ;
$loginhtmltext .= '<br><b>' . $langs -> trans ( " ConnectedSince " ) . '</b>: ' . dol_print_date ( $user -> datelastlogin , " dayhour " );
$loginhtmltext .= '<br><b>' . $langs -> trans ( " PreviousConnexion " ) . '</b>: ' . dol_print_date ( $user -> datepreviouslogin , " dayhour " );
$loginhtmltext .= '<br><b>' . $langs -> trans ( " AuthenticationMode " ) . '</b>: ' . $_SESSION [ " dol_authmode " ];
$loginhtmltext .= '<br><b>' . $langs -> trans ( " CurrentTheme " ) . '</b>: ' . $conf -> theme ;
$s = picto_from_langcode ( $langs -> getDefaultLang ());
$loginhtmltext .= '<br><b>' . $langs -> trans ( " CurrentUserLanguage " ) . '</b>: ' . ( $s ? $s . ' ' : '' ) . $langs -> getDefaultLang ();
$loginhtmltext .= '<br><b>' . $langs -> trans ( " Browser " ) . '</b>: ' . $conf -> browser -> name . ' (' . $_SERVER [ 'HTTP_USER_AGENT' ] . ')' ;
if ( ! empty ( $conf -> browser -> phone )) $loginhtmltext .= '<br><b>' . $langs -> trans ( " Phone " ) . '</b>: ' . $conf -> browser -> phone ;
if ( ! empty ( $_SESSION [ " disablemodules " ])) $loginhtmltext .= '<br><b>' . $langs -> trans ( " DisabledModules " ) . '</b>: <br>' . join ( '<br>' , explode ( ',' , $_SESSION [ " disablemodules " ]));
2010-04-05 20:41:34 +02:00
// Link info
2010-06-27 15:19:38 +02:00
$logouthtmltext = '' ; $logouttext = '' ;
$logouthtmltext = $langs -> trans ( " Logout " ) . '<br>' ;
//$logouthtmltext.="<br>";
2010-04-05 20:41:34 +02:00
if ( $_SESSION [ " dol_authmode " ] != 'forceuser'
&& $_SESSION [ " dol_authmode " ] != 'http' )
{
2010-06-27 15:19:38 +02:00
$logouttext .= '<a href="' . DOL_URL_ROOT . '/user/logout.php"' ;
$logouttext .= $menutop -> atarget ? ( ' target="' . $menutop -> atarget . '"' ) : '' ;
$logouttext .= '>' ;
$logouttext .= '<img class="login" border="0" width="14" height="14" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/logout.png"' ;
$logouttext .= ' alt="' . dol_escape_htmltag ( $langs -> trans ( " Logout " )) . '" title=""' ;
$logouttext .= '>' ;
$logouttext .= '</a>' ;
2010-04-05 20:41:34 +02:00
}
else
{
2010-06-27 15:19:38 +02:00
$logouttext .= '<img class="login" border="0" width="14" height="14" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/logout.png"' ;
$logouttext .= ' alt="' . dol_escape_htmltag ( $langs -> trans ( " Logout " )) . '" title=""' ;
$logouttext .= '>' ;
2010-04-05 20:41:34 +02:00
}
2011-01-23 16:08:21 +01:00
2011-01-10 09:13:31 +01:00
print '<div class="login_block">' . " \n " ;
2011-02-03 23:11:45 +01:00
print '<table class="nobordernopadding" summary=""><tr>' ;
2010-10-22 04:00:50 +02:00
2011-02-03 23:11:45 +01:00
print $html -> textwithtooltip ( '' , $loginhtmltext , 2 , 1 , $logintext , '' , 1 );
2011-01-23 16:08:21 +01:00
2011-01-10 09:13:31 +01:00
// Select entity
if ( ! empty ( $conf -> global -> MAIN_MODULE_MULTICOMPANY ))
{
if ( $user -> admin && ! $user -> entity )
{
$res =@ dol_include_once ( '/multicompany/class/actions_multicompany.class.php' );
if ( $res )
{
//$mc = new ActionsMulticompany($db);
2011-01-17 17:02:04 +01:00
$entitytext = img_object ( '' , 'globe' , " class='entity' " );
2011-01-10 09:13:31 +01:00
$entityhtmltext = 'EntityName' ;
2011-02-03 23:11:45 +01:00
print $html -> textwithtooltip ( '' , $entityhtmltext , 2 , 1 , $entitytext , '' , 1 );
2011-01-10 09:13:31 +01:00
//$select_entity = '<div class="loginSelectEntity">'.$mc->select_entities($conf->entity).'</div>';
//if ($mc->numEntity >= 1) print $select_entity;
}
}
}
2010-06-27 15:19:38 +02:00
2011-02-03 23:11:45 +01:00
print $html -> textwithtooltip ( '' , $logouthtmltext , 2 , 1 , $logouttext , '' , 1 );
2010-04-05 20:41:34 +02:00
// Link to print main content area
if ( empty ( $conf -> global -> MAIN_PRINT_DISABLELINK ) && empty ( $conf -> browser -> phone ))
{
2011-01-19 11:37:59 +01:00
$qs = $_SERVER [ " QUERY_STRING " ] . ( $_SERVER [ " QUERY_STRING " ] ? '&' : '' ) . $morequerystring ;
$text = '<a href="' . $_SERVER [ " PHP_SELF " ] . '?' . $qs . ( $qs ? '&' : '' ) . 'optioncss=print" target="_blank">' ;
2010-04-05 20:41:34 +02:00
$text .= '<img class="printer" border="0" width="14" height="14" src="' . DOL_URL_ROOT . '/theme/' . $conf -> theme . '/img/printer.png"' ;
2010-06-27 15:19:38 +02:00
$text .= ' title="" alt="">' ;
2010-04-05 20:41:34 +02:00
$text .= '</a>' ;
2011-02-03 23:11:45 +01:00
print $html -> textwithtooltip ( '' , $langs -> trans ( " PrintContentArea " ), 2 , 1 , $text , '' , 1 );
2010-04-05 20:41:34 +02:00
}
2011-02-03 23:11:45 +01:00
print '</tr></table>' . " \n " ;
print " </div> \n " ;
2010-11-02 13:14:06 +01:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) print " </div><!-- End top layout --> \n " ;
2010-11-02 13:28:27 +01:00
print " <!-- End top horizontal menu --> \n " ;
if ( ! $conf -> use_javascript_ajax || ! $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) print '<table width="100%" class="notopnoleftnoright" summary="leftmenutable" id="undertopmenu"><tr>' ;
2010-04-05 20:41:34 +02:00
}
2005-01-01 20:48:22 +01:00
/**
2010-11-05 21:11:33 +01:00
* Show left menu bar
* @ param menu_array_before Table of menu entries to show before entries of menu handler
* @ param helppagename Name of wiki page for help ( '' by default ) .
* Syntax is : For a wiki page : EN : EnglishPage | FR : FrenchPage | ES : SpanishPage
* For other external page : http :// server / url
* @ param moresearchform Search Form Permanent Supplemental
* @ param menu_array_after Table of menu entries to show after entries of menu handler
* @ param leftmenuwithoutmainarea Must be set to 1. 0 by default for backward compatibility with old modules .
2003-01-13 22:33:41 +01:00
*/
2010-11-05 21:11:33 +01:00
function left_menu ( $menu_array_before , $helppagename = '' , $moresearchform = '' , $menu_array_after = '' , $leftmenuwithoutmainarea = 0 )
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";
2010-11-02 13:14:06 +01:00
2010-11-02 13:03:29 +01:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) print " \n " . '<div class="ui-layout-west"> <!-- Begin left layout -->' . " \n " ;
2010-11-19 16:37:33 +01:00
else print '<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 " );
2010-07-21 23:58:46 +02:00
$searchform .= printSearchForm ( DOL_URL_ROOT . '/societe/societe.php' , DOL_URL_ROOT . '/societe/societe.php' ,
2010-10-09 13:40:59 +02:00
img_object ( '' , 'company' ) . ' ' . $langs -> trans ( " ThirdParties " ), '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
2010-05-10 06:50:39 +02:00
if ((( $conf -> product -> 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 " );
2010-07-28 01:36:24 +02:00
$searchform .= printSearchForm ( DOL_URL_ROOT . '/product/liste.php' , DOL_URL_ROOT . '/product/liste.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 );
}
2010-09-29 12:10:33 +02:00
//$left_menu=$conf->left_menu;
$left_menu = $conf -> top_menu ;
2010-11-11 00:18:23 +01:00
if ( GETPOST ( 'menu' )) $left_menu = GETPOST ( 'menu' ); // menu=eldy_backoffice.php
2009-02-24 03:41:21 +01:00
2010-09-03 23:34:07 +02:00
// Load the left menu manager
2011-01-23 16:08:21 +01:00
$result = dol_include_once ( " /includes/menus/standard/ " . $left_menu );
2010-12-29 13:13:36 +01:00
if ( ! $result ) // If menu manager removed or not found
2009-02-24 03:41:21 +01:00
{
2010-09-29 12:10:33 +02:00
$left_menu = 'eldy_backoffice.php' ;
2010-10-02 23:31:14 +02:00
include_once ( DOL_DOCUMENT_ROOT . " /includes/menus/standard/ " . $left_menu );
2009-02-24 03:41:21 +01:00
}
2010-09-29 13:57:09 +02:00
// Left column
print '<!-- Begin left vertical menu ' . $left_menu . ' -->' . " \n " ;
2010-11-02 13:14:06 +01:00
2010-09-29 13:57:09 +02:00
print '<div class="vmenu">' . " \n " ;
2010-07-27 00:03:50 +02:00
$menuleft = new MenuLeft ( $db , $menu_array_before , $menu_array_after );
$menuleft -> showmenu (); // output menu_array and menu found in database
2009-02-24 03:41:21 +01:00
2010-07-27 00:03:50 +02:00
// Show other forms
2009-02-24 03:41:21 +01:00
if ( $searchform )
2008-12-10 16:17:04 +01:00
{
print " \n " ;
print " <!-- Begin SearchForm --> \n " ;
2010-06-26 02:16:59 +02:00
print '<div id="blockvmenusearch" class="blockvmenusearch">' . " \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
2010-07-27 00:03:50 +02:00
// More search form
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
2010-07-27 00:03:50 +02:00
// Bookmarks
2009-02-24 03:41:21 +01:00
if ( $bookmarks )
2009-01-23 01:47:23 +01:00
{
print " \n " ;
print " <!-- Begin Bookmarks --> \n " ;
2010-06-26 02:16:59 +02:00
print '<div id="blockvmenubookmarks" class="blockvmenubookmarks">' . " \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-10-04 00:32:10 +02:00
$helppage = '' ;
$mode = '' ;
// Get helpbaseurl, helppage and mode from helppagename and langs
$arrayres = getHelpParamFor ( $helppagename , $langs );
$helpbaseurl = $arrayres [ 'helpbaseurl' ];
$helppage = $arrayres [ 'helppage' ];
$mode = $arrayres [ 'mode' ];
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
{
2010-06-26 02:16:59 +02:00
print '<div id="blockvmenuhelp" class="blockvmenuhelp">' ;
2009-08-09 02:35:17 +02:00
print '<a class="help" target="_blank" title="' . $langs -> trans ( $mode == 'wiki' ? 'GoToWikiHelpPage' : 'GoToHelpPage' );
2009-11-02 19:53:26 +01:00
if ( $mode == 'wiki' ) print ' - ' . $langs -> trans ( " PageWiki " ) . ' "' . dol_escape_htmltag ( strtr ( $helppage , '_' , ' ' )) . '"' ;
2009-05-18 13:40:33 +02:00
print '" href="' ;
2009-11-07 14:57:47 +01:00
print sprintf ( $helpbaseurl , urlencode ( html_entity_decode ( $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
}
2010-07-27 00:03:50 +02:00
// Link to bugtrack
2009-01-21 14:06:34 +01:00
if ( ! empty ( $conf -> global -> MAIN_SHOW_BUGTRACK_LINK ))
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 " ;
2010-11-02 13:14:06 +01:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) print '</div> <!-- End left layout -->' . " \n " ;
else print '</td>' ;
2008-09-30 02:10:49 +02:00
2010-11-02 13:28:27 +01:00
print " \n " . '<!-- End of left column, begin right area -->' . " \n \n " ;
2008-09-30 02:10:49 +02:00
// print '</div>'."\n";
// print '<div class="vmenuplusfiche">'."\n";
2010-11-05 21:11:33 +01:00
if ( empty ( $leftmenuwithoutmainarea )) main_area ();
2010-10-29 19:54:15 +02:00
}
2008-09-30 02:10:49 +02:00
2010-10-29 19:54:15 +02:00
/**
* Begin main area
*/
function main_area ()
{
global $conf , $langs ;
2010-11-02 13:14:06 +01:00
2010-11-19 16:37:33 +01:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT )
{
print '<div id="mainContent"><div class="ui-layout-center"> <!-- begin main layout -->' . " \n " ;
print '<table width="100%" class="notopnoleftnoright" summary="centermenutable" id="undertopmenu"><tr>' ;
}
2010-11-02 13:14:06 +01:00
print '<td valign="top"><!-- Begin right area --> ' . " \n " ;
2008-06-19 00:56:02 +02:00
print " \n " ;
2010-11-02 13:14:06 +01:00
print '<div class="fiche"> <!-- begin div class="fiche" -->' . " \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
2009-10-04 00:32:10 +02:00
/**
* \brief Return helpbaseurl , helppage and mode
* \param helppagename Page name ( EN : xxx , ES : eee , FR : fff ... )
* \param langs Language
*/
function getHelpParamFor ( $helppagename , $langs )
{
2009-10-24 08:10:00 +02:00
if ( preg_match ( '/^http/i' , $helppagename ))
2009-10-04 00:32:10 +02:00
{
// If complete URL
$helpbaseurl = '%s' ;
$helppage = $helppagename ;
$mode = 'local' ;
}
else
{
// If WIKI URL
2009-10-24 08:10:00 +02:00
if ( preg_match ( '/^es/i' , $langs -> defaultlang ))
2009-10-04 00:32:10 +02:00
{
$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s' ;
2009-10-24 08:10:00 +02:00
if ( preg_match ( '/ES:([^|]+)/i' , $helppagename , $reg )) $helppage = $reg [ 1 ];
2009-10-04 00:32:10 +02:00
}
2009-10-24 08:10:00 +02:00
if ( preg_match ( '/^fr/i' , $langs -> defaultlang ))
2009-10-04 00:32:10 +02:00
{
$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s' ;
2009-10-24 08:10:00 +02:00
if ( preg_match ( '/FR:([^|]+)/i' , $helppagename , $reg )) $helppage = $reg [ 1 ];
2009-10-04 00:32:10 +02:00
}
if ( empty ( $helppage )) // If help page not already found
{
$helpbaseurl = 'http://wiki.dolibarr.org/index.php/%s' ;
2009-10-24 08:10:00 +02:00
if ( preg_match ( '/EN:([^|]+)/i' , $helppagename , $reg )) $helppage = $reg [ 1 ];
2009-10-04 00:32:10 +02:00
}
$mode = 'wiki' ;
}
return array ( 'helpbaseurl' => $helpbaseurl , 'helppage' => $helppage , 'mode' => $mode );
}
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
2010-02-19 14:50:49 +01:00
* \param urlaction Url post
* \param urlobject Url of the link under the search box
* \param title Title search area
2005-10-31 05:57:20 +01:00
* \param htmlmodesearch 'search'
2010-02-19 14:50:49 +01:00
* \param htmlinputname Field Name input form
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
}
2010-08-24 13:04:16 +02:00
/**
* Return list of login method of third party module .
* @ return array
*/
function getLoginMethod ()
{
global $conf , $langs ;
2010-08-26 04:07:52 +02:00
2010-08-24 13:04:16 +02:00
$login = '' ;
foreach ( $conf -> login_method_modules as $dir )
{
// Check if directory exists
if ( ! is_dir ( $dir )) continue ;
2010-08-26 04:07:52 +02:00
2010-08-24 13:04:16 +02:00
$handle = opendir ( $dir );
2010-12-15 19:15:08 +01:00
if ( is_resource ( $handle ))
{
while (( $file = readdir ( $handle )) !== false )
{
if ( is_readable ( $dir . '/' . $file ) && preg_match ( '/^functions_([^_]+)\.php/' , $file , $reg ))
{
$authfile = $dir . '/' . $file ;
$mode = $reg [ 1 ];
$result = include_once ( $authfile );
if ( $result )
{
// Call function to check user/password
$usertotest = $_POST [ " username " ];
$passwordtotest = $_POST [ " password " ];
$function = 'check_user_password_' . $mode ;
$login = $function ( $usertotest , $passwordtotest );
if ( $login )
{
$conf -> authmode = $mode ; // This properties is defined only when logged
}
}
else
{
dol_syslog ( " Authentification ko - failed to load file ' " . $authfile . " ' " , LOG_ERR );
sleep ( 1 );
$langs -> load ( 'main' );
$langs -> load ( 'other' );
$_SESSION [ " dol_loginmesg " ] = $langs -> trans ( " ErrorFailedToLoadLoginFileForMode " , $mode );
}
}
}
}
2010-08-24 13:04:16 +02:00
closedir ( $handle );
}
return $login ;
}
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
*/
2010-03-16 02:18:25 +01:00
if ( ! function_exists ( " llxFooter " ))
2002-12-12 17:42:08 +01:00
{
2010-03-16 02:18:25 +01:00
function llxFooter ( $foot = '' )
{
2010-10-03 23:43:03 +02:00
global $conf , $langs , $dolibarr_auto_user , $micro_start_time ;
2010-10-09 13:40:59 +02:00
2010-10-03 23:43:03 +02:00
// Core error message
if ( defined ( " MAIN_CORE_ERROR " ) && constant ( " MAIN_CORE_ERROR " ) == 1 )
{
// Ajax version
if ( $conf -> use_javascript_ajax )
{
$title = img_warning () . ' ' . $langs -> trans ( 'CoreErrorTitle' );
print ajax_dialog ( $title , $langs -> trans ( 'CoreErrorMessage' ));
}
// html version
else
{
$msg = img_warning () . ' ' . $langs -> trans ( 'CoreErrorMessage' );
print '<div class="error">' . $msg . '</div>' ;
}
2010-10-09 13:40:59 +02:00
2010-10-03 23:43:03 +02:00
define ( " MAIN_CORE_ERROR " , 0 );
}
2008-09-30 02:10:49 +02:00
2010-03-16 02:18:25 +01:00
print " \n \n " . '</div> <!-- end div class="fiche" -->' . " \n " ;
2008-06-19 00:56:02 +02:00
2010-03-16 02:18:25 +01:00
// print "\n".'</div> <!-- end div class="vmenuplusfiche" -->'."\n";
print " \n " . '</td></tr></table> <!-- end right area -->' . " \n " ;
2010-11-02 13:14:06 +01:00
if ( $conf -> use_javascript_ajax && $conf -> global -> MAIN_MENU_USE_JQUERY_LAYOUT ) print '</div></div> <!-- end main layout -->' . " \n " ;
2008-09-30 02:10:49 +02:00
2010-03-16 02:18:25 +01:00
if ( ! empty ( $_SERVER [ 'DOL_TUNING' ]))
2009-02-21 02:04:35 +01:00
{
2010-03-16 02:18:25 +01:00
$micro_end_time = dol_microtime_float ( true );
2010-05-26 00:55:56 +02:00
print " \n " . '<script type="text/javascript">window.status="' ;
if ( ! empty ( $conf -> global -> MEMCACHED_SERVER )) print 'MEMCACHED_SERVER=' . $conf -> global -> MEMCACHED_SERVER . ' - ' ;
print 'MAIN_OPTIMIZE_SPEED=' . ( isset ( $conf -> global -> MAIN_OPTIMIZE_SPEED ) ? $conf -> global -> MAIN_OPTIMIZE_SPEED : 'off' );
print ' - Build time: ' . ceil ( 1000 * ( $micro_end_time - $micro_start_time )) . ' ms' ;
2010-03-16 02:18:25 +01:00
if ( function_exists ( " memory_get_usage " ))
{
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 ();
}
if ( function_exists ( " zend_loader_file_encoded " ))
{
print ' - Zend encoded file: ' . ( zend_loader_file_encoded () ? 'yes' : 'no' );
}
print '"</script>' . " \n " ;
// Add Xdebug coverage of code
if ( defined ( 'XDEBUGCOVERAGE' )) { var_dump ( xdebug_get_code_coverage ()); }
2007-09-16 00:42:19 +02:00
}
2010-03-16 02:18:25 +01:00
// If there is some logs in buffer to show
if ( sizeof ( $conf -> logbuffer ))
2009-05-07 01:30:49 +02:00
{
2010-03-16 02:18:25 +01:00
print " \n " ;
print " <!-- Start of log output \n " ;
//print '<div class="hidden">'."\n";
foreach ( $conf -> logbuffer as $logline )
{
print $logline . " <br> \n " ;
}
//print '</div>'."\n";
print " End of log output --> \n " ;
2009-05-07 01:30:49 +02:00
}
2009-01-21 14:06:34 +01:00
2010-03-16 02:18:25 +01:00
print " \n " ;
if ( $foot ) print '<!-- ' . $foot . ' -->' . " \n " ;
2009-02-20 23:53:15 +01:00
2010-03-16 02:18:25 +01:00
if ( ! empty ( $conf -> global -> MAIN_HTML_FOOTER )) print $conf -> global -> MAIN_HTML_FOOTER . " \n " ;
2009-10-16 19:15:32 +02:00
2010-03-16 02:18:25 +01:00
print " </body> \n " ;
print " </html> \n " ;
}
2002-05-09 16:57:48 +02:00
}
2007-01-03 01:07:57 +01:00
2010-08-24 13:04:16 +02:00
?>