filefunc.inc.php 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381
  1. <?php
  2. /* Copyright (C) 2002-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  3. * Copyright (C) 2003 Xavier Dutoit <doli@sydesy.com>
  4. * Copyright (C) 2004-2017 Laurent Destailleur <eldy@users.sourceforge.net>
  5. * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
  6. * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
  7. * Copyright (C) 2005-2011 Regis Houssin <regis.houssin@inodbox.com>
  8. * Copyright (C) 2005 Simon Tosser <simon@kornog-computing.com>
  9. * Copyright (C) 2006 Andre Cianfarani <andre.cianfarani@acdeveloppement.net>
  10. * Copyright (C) 2010 Juanjo Menent <jmenent@2byte.es>
  11. * Copyright (C) 2015 Bahfir Abbes <bafbes@gmail.com>
  12. *
  13. * This program is free software; you can redistribute it and/or modify
  14. * it under the terms of the GNU General Public License as published by
  15. * the Free Software Foundation; either version 3 of the License, or
  16. * (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program. If not, see <https://www.gnu.org/licenses/>.
  25. */
  26. /**
  27. * \file htdocs/filefunc.inc.php
  28. * \ingroup core
  29. * \brief File that include conf.php file and commons lib like functions.lib.php
  30. */
  31. if (!defined('DOL_APPLICATION_TITLE')) {
  32. define('DOL_APPLICATION_TITLE', 'Dolibarr');
  33. }
  34. if (!defined('DOL_VERSION')) {
  35. define('DOL_VERSION', '19.0.1'); // a.b.c-alpha, a.b.c-beta, a.b.c-rcX or a.b.c
  36. }
  37. if (!defined('EURO')) {
  38. define('EURO', chr(128));
  39. }
  40. // Define syslog constants
  41. if (!defined('LOG_DEBUG')) {
  42. if (!function_exists("syslog")) {
  43. // For PHP versions without syslog (like running on Windows OS)
  44. define('LOG_EMERG', 0);
  45. define('LOG_ALERT', 1);
  46. define('LOG_CRIT', 2);
  47. define('LOG_ERR', 3);
  48. define('LOG_WARNING', 4);
  49. define('LOG_NOTICE', 5);
  50. define('LOG_INFO', 6);
  51. define('LOG_DEBUG', 7);
  52. }
  53. }
  54. // End of common declaration part
  55. if (defined('DOL_INC_FOR_VERSION_ERROR')) {
  56. return;
  57. }
  58. // Define vars
  59. $conffiletoshowshort = "conf.php";
  60. // Define localization of conf file
  61. // --- Start of part replaced by Dolibarr packager makepack-dolibarr
  62. $conffile = "conf/conf.php";
  63. $conffiletoshow = "htdocs/conf/conf.php";
  64. // For debian/redhat like systems
  65. //$conffile = "/etc/dolibarr/conf.php";
  66. //$conffiletoshow = "/etc/dolibarr/conf.php";
  67. // Include configuration
  68. // --- End of part replaced by Dolibarr packager makepack-dolibarr
  69. // Include configuration
  70. $result = @include_once $conffile; // Keep @ because with some error reporting this break the redirect done when file not found
  71. // Disable some not used PHP stream
  72. $listofwrappers = stream_get_wrappers();
  73. // We need '.phar' for geoip2. TODO Replace phar in geoip with exploded files so we can disable phar by default.
  74. // phar stream does not auto unserialize content (possible code execution) since PHP 8.1
  75. // $arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zip', 'zlib');
  76. // zip stream is necessary in import module
  77. $arrayofstreamtodisable = array('compress.zlib', 'compress.bzip2', 'ftp', 'ftps', 'glob', 'data', 'expect', 'ogg', 'rar', 'zlib');
  78. if (!empty($dolibarr_main_stream_to_disable) && is_array($dolibarr_main_stream_to_disable)) {
  79. $arrayofstreamtodisable = $dolibarr_main_stream_to_disable;
  80. }
  81. foreach ($arrayofstreamtodisable as $streamtodisable) {
  82. if (!empty($listofwrappers) && in_array($streamtodisable, $listofwrappers)) {
  83. /*if (!empty($dolibarr_main_stream_do_not_disable) && is_array($dolibarr_main_stream_do_not_disable) && in_array($streamtodisable, $dolibarr_main_stream_do_not_disable)) {
  84. continue; // We do not disable this stream
  85. }*/
  86. stream_wrapper_unregister($streamtodisable);
  87. }
  88. }
  89. if (!$result && !empty($_SERVER["GATEWAY_INTERFACE"])) { // If install not done and we are in a web session
  90. if (!empty($_SERVER["CONTEXT_PREFIX"])) { // CONTEXT_PREFIX and CONTEXT_DOCUMENT_ROOT are not defined on all apache versions
  91. $path = $_SERVER["CONTEXT_PREFIX"]; // example '/dolibarr/' when using an apache alias.
  92. if (!preg_match('/\/$/', $path)) {
  93. $path .= '/';
  94. }
  95. } elseif (preg_match('/index\.php/', $_SERVER['PHP_SELF'])) {
  96. // When we ask index.php, we MUST BE SURE that $path is '' at the end. This is required to make install process
  97. // when using apache alias like '/dolibarr/' that point to htdocs.
  98. // Note: If calling page was an index.php not into htdocs (ie comm/index.php, ...), then this redirect will fails,
  99. // but we don't want to change this because when URL is correct, we must be sure the redirect to install/index.php will be correct.
  100. $path = '';
  101. } else {
  102. // If what we look is not index.php, we can try to guess location of root. May not work all the time.
  103. // There is no real solution, because the only way to know the apache url relative path is to have it into conf file.
  104. // If it fails to find correct $path, then only solution is to ask user to enter the correct URL to index.php or install/index.php
  105. $TDir = explode('/', $_SERVER['PHP_SELF']);
  106. $path = '';
  107. $i = count($TDir);
  108. while ($i--) {
  109. if (empty($TDir[$i]) || $TDir[$i] == 'htdocs') {
  110. break;
  111. }
  112. if ($TDir[$i] == 'dolibarr') {
  113. break;
  114. }
  115. if (substr($TDir[$i], -4, 4) == '.php') {
  116. continue;
  117. }
  118. $path .= '../';
  119. }
  120. }
  121. header("Location: ".$path."install/index.php");
  122. /*
  123. print '<br><center>';
  124. print 'The conf/conf.php file was not found or is not readable by the web server. If this is your first access, <a href="'.$path.'install/index.php">click here to start the Dolibarr installation process</a> to create it...';
  125. print '</center><br>';
  126. */
  127. exit;
  128. }
  129. // Force PHP error_reporting setup (Dolibarr may report warning without this)
  130. if (!empty($dolibarr_strict_mode)) {
  131. error_reporting(E_ALL | E_STRICT);
  132. } else {
  133. error_reporting(E_ALL & ~(E_STRICT | E_NOTICE | E_DEPRECATED));
  134. }
  135. // Disable php display errors
  136. if (!empty($dolibarr_main_prod)) {
  137. ini_set('display_errors', 'Off');
  138. }
  139. // Clean parameters
  140. $dolibarr_main_data_root = (empty($dolibarr_main_data_root) ? '' : trim($dolibarr_main_data_root));
  141. $dolibarr_main_url_root = trim(preg_replace('/\/+$/', '', empty($dolibarr_main_url_root) ? '' : $dolibarr_main_url_root));
  142. $dolibarr_main_url_root_alt = (empty($dolibarr_main_url_root_alt) ? '' : trim($dolibarr_main_url_root_alt));
  143. $dolibarr_main_document_root = (empty($dolibarr_main_document_root) ? '' : trim($dolibarr_main_document_root));
  144. $dolibarr_main_document_root_alt = (empty($dolibarr_main_document_root_alt) ? '' : trim($dolibarr_main_document_root_alt));
  145. if (empty($dolibarr_main_db_port)) {
  146. $dolibarr_main_db_port = 3306; // For compatibility with old configs, if not defined, we take 'mysql' type
  147. }
  148. if (empty($dolibarr_main_db_type)) {
  149. $dolibarr_main_db_type = 'mysqli'; // For compatibility with old configs, if not defined, we take 'mysql' type
  150. }
  151. // Mysql driver support has been removed in favor of mysqli
  152. if ($dolibarr_main_db_type == 'mysql') {
  153. $dolibarr_main_db_type = 'mysqli';
  154. }
  155. if (empty($dolibarr_main_db_prefix)) {
  156. $dolibarr_main_db_prefix = 'llx_';
  157. }
  158. if (empty($dolibarr_main_db_character_set)) {
  159. $dolibarr_main_db_character_set = ($dolibarr_main_db_type == 'mysqli' ? 'utf8' : ''); // Old installation
  160. }
  161. if (empty($dolibarr_main_db_collation)) {
  162. $dolibarr_main_db_collation = ($dolibarr_main_db_type == 'mysqli' ? 'utf8_unicode_ci' : ''); // Old installation
  163. }
  164. if (empty($dolibarr_main_db_encryption)) {
  165. $dolibarr_main_db_encryption = 0;
  166. }
  167. if (empty($dolibarr_main_db_cryptkey)) {
  168. $dolibarr_main_db_cryptkey = '';
  169. }
  170. if (empty($dolibarr_main_limit_users)) {
  171. $dolibarr_main_limit_users = 0;
  172. }
  173. if (empty($dolibarr_mailing_limit_sendbyweb)) {
  174. $dolibarr_mailing_limit_sendbyweb = 0;
  175. }
  176. if (empty($dolibarr_mailing_limit_sendbycli)) {
  177. $dolibarr_mailing_limit_sendbycli = 0;
  178. }
  179. if (empty($dolibarr_mailing_limit_sendbyday)) {
  180. $dolibarr_mailing_limit_sendbyday = 0;
  181. }
  182. if (empty($dolibarr_strict_mode)) {
  183. $dolibarr_strict_mode = 0; // For debug in php strict mode
  184. }
  185. define('DOL_DOCUMENT_ROOT', $dolibarr_main_document_root); // Filesystem core php (htdocs)
  186. if (!file_exists(DOL_DOCUMENT_ROOT."/core/lib/functions.lib.php")) {
  187. print "Error: Dolibarr config file content seems to be not correctly defined.<br>\n";
  188. print "Please run dolibarr setup by calling page <b>/install</b>.<br>\n";
  189. exit;
  190. }
  191. // Included by default (must be before the CSRF check so wa can use the dol_syslog)
  192. include_once DOL_DOCUMENT_ROOT.'/core/lib/functions.lib.php';
  193. include_once DOL_DOCUMENT_ROOT.'/core/lib/security.lib.php';
  194. //print memory_get_usage();
  195. // Security: CSRF protection
  196. // This test check if referrer ($_SERVER['HTTP_REFERER']) is same web site than Dolibarr ($_SERVER['HTTP_HOST'])
  197. // when we post forms (we allow GET and HEAD to accept direct link from a particular page).
  198. // Note about $_SERVER[HTTP_HOST/SERVER_NAME]: http://shiflett.org/blog/2006/mar/server-name-versus-http-host
  199. // See also CSRF protections done into main.inc.php
  200. if (!defined('NOCSRFCHECK') && isset($dolibarr_nocsrfcheck) && $dolibarr_nocsrfcheck == 1) { // If $dolibarr_nocsrfcheck is 0, there is a strict CSRF test with token in main
  201. if (!empty($_SERVER['REQUEST_METHOD']) && !in_array($_SERVER['REQUEST_METHOD'], array('GET', 'HEAD')) && !empty($_SERVER['HTTP_HOST'])) {
  202. $csrfattack = false;
  203. if (empty($_SERVER['HTTP_REFERER'])) {
  204. $csrfattack = true; // An evil browser was used
  205. } else {
  206. $tmpa = parse_url($_SERVER['HTTP_HOST']);
  207. $tmpb = parse_url($_SERVER['HTTP_REFERER']);
  208. if ((empty($tmpa['host']) ? $tmpa['path'] : $tmpa['host']) != (empty($tmpb['host']) ? $tmpb['path'] : $tmpb['host'])) {
  209. $csrfattack = true;
  210. }
  211. }
  212. if ($csrfattack) {
  213. //print 'NOCSRFCHECK='.defined('NOCSRFCHECK').' REQUEST_METHOD='.$_SERVER['REQUEST_METHOD'].' HTTP_HOST='.$_SERVER['HTTP_HOST'].' HTTP_REFERER='.$_SERVER['HTTP_REFERER'];
  214. // Note: We can't use dol_escape_htmltag here to escape output because lib functions.lib.ph is not yet loaded.
  215. dol_syslog("--- Access to ".(empty($_SERVER["REQUEST_METHOD"])?'':$_SERVER["REQUEST_METHOD"].' ').$_SERVER["PHP_SELF"]." refused by CSRF protection (Bad referer).", LOG_WARNING);
  216. print "Access refused by CSRF protection in main.inc.php. Referer of form (".htmlentities($_SERVER['HTTP_REFERER'], ENT_COMPAT, 'UTF-8').") is outside the server that serve this page (with method = ".htmlentities($_SERVER['REQUEST_METHOD'], ENT_COMPAT, 'UTF-8').").\n";
  217. print "If you access your server behind a proxy using url rewriting, you might check that all HTTP headers are propagated (or add the line \$dolibarr_nocsrfcheck=1 into your conf.php file to remove this security check).\n";
  218. die;
  219. }
  220. }
  221. // Another test is done later on token if option MAIN_SECURITY_CSRF_WITH_TOKEN is on.
  222. }
  223. if (empty($dolibarr_main_db_host) && !defined('NOREQUIREDB')) {
  224. print '<div class="center">Dolibarr setup is not yet complete.<br><br>'."\n";
  225. print '<a href="install/index.php">Click here to finish Dolibarr install process</a> ...</div>'."\n";
  226. die;
  227. }
  228. if (empty($dolibarr_main_url_root) && !defined('NOREQUIREVIRTUALURL')) {
  229. print 'Value for parameter \'dolibarr_main_url_root\' is not defined in your \'htdocs\conf\conf.php\' file.<br>'."\n";
  230. print 'You must add this parameter with your full Dolibarr root Url (Example: http://myvirtualdomain/ or http://mydomain/mydolibarrurl/)'."\n";
  231. die;
  232. }
  233. if (empty($dolibarr_main_document_root_alt)) {
  234. $dolibarr_main_document_root_alt = $dolibarr_main_document_root.'/custom';
  235. }
  236. if (empty($dolibarr_main_data_root)) {
  237. // If directory not defined, we use the default hardcoded value
  238. $dolibarr_main_data_root = str_replace("/htdocs", "", $dolibarr_main_document_root);
  239. $dolibarr_main_data_root .= "/documents";
  240. }
  241. // Define some constants
  242. define('DOL_CLASS_PATH', 'class/'); // Filesystem path to class dir (defined only for some code that want to be compatible with old versions without this parameter)
  243. define('DOL_DATA_ROOT', $dolibarr_main_data_root); // Filesystem data (documents)
  244. // Try to autodetect DOL_MAIN_URL_ROOT and DOL_URL_ROOT when root is not directly the main domain.
  245. // Note: autodetect works only in case 1, 2, 3 and 4 of phpunit test CoreTest.php. For case 5, 6, only setting value into conf.php will works.
  246. $tmp = '';
  247. $found = 0;
  248. $real_dolibarr_main_document_root = str_replace('\\', '/', realpath($dolibarr_main_document_root)); // A) Value found into config file, to say where are store htdocs files. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
  249. if (!empty($_SERVER["DOCUMENT_ROOT"])) {
  250. $pathroot = $_SERVER["DOCUMENT_ROOT"]; // B) Value reported by web server setup (not defined on CLI mode), to say where is root of web server instance. Ex: C:/xxx/dolibarr, C:/xxx/dolibarr/htdocs
  251. } else {
  252. $pathroot = 'NOTDEFINED';
  253. }
  254. $paths = explode('/', str_replace('\\', '/', $_SERVER["SCRIPT_NAME"])); // C) Value reported by web server, to say full path on filesystem of a file. Ex: /dolibarr/htdocs/admin/system/phpinfo.php
  255. // Try to detect if $_SERVER["DOCUMENT_ROOT"]+start of $_SERVER["SCRIPT_NAME"] is $dolibarr_main_document_root. If yes, relative url to add before dol files is this start part.
  256. $concatpath = '';
  257. foreach ($paths as $tmppath) { // We check to find (B+start of C)=A
  258. if (empty($tmppath)) {
  259. continue;
  260. }
  261. $concatpath .= '/'.$tmppath;
  262. //if ($tmppath) $concatpath.='/'.$tmppath;
  263. //print $_SERVER["SCRIPT_NAME"].'-'.$pathroot.'-'.$concatpath.'-'.$real_dolibarr_main_document_root.'-'.realpath($pathroot.$concatpath).'<br>';
  264. if ($real_dolibarr_main_document_root == @realpath($pathroot.$concatpath)) { // @ avoid warning when safe_mode is on.
  265. //print "Found relative url = ".$concatpath;
  266. $tmp3 = $concatpath;
  267. $found = 1;
  268. break;
  269. }
  270. //else print "Not found yet for concatpath=".$concatpath."<br>\n";
  271. }
  272. //print "found=".$found." dolibarr_main_url_root=".$dolibarr_main_url_root."\n";
  273. if (!$found) {
  274. // There is no subdir that compose the main url root or autodetect fails (Ie: when using apache alias that point outside default DOCUMENT_ROOT).
  275. $tmp = $dolibarr_main_url_root;
  276. } else {
  277. $tmp = 'http'.(((empty($_SERVER["HTTPS"]) || $_SERVER["HTTPS"] != 'on') && (empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] != 443)) ? '' : 's').'://'.$_SERVER["SERVER_NAME"].((empty($_SERVER["SERVER_PORT"]) || $_SERVER["SERVER_PORT"] == 80 || $_SERVER["SERVER_PORT"] == 443) ? '' : ':'.$_SERVER["SERVER_PORT"]).($tmp3 ? (preg_match('/^\//', $tmp3) ? '' : '/').$tmp3 : '');
  278. }
  279. //print "tmp1=".$tmp1." tmp2=".$tmp2." tmp3=".$tmp3." tmp=".$tmp."\n";
  280. if (!empty($dolibarr_main_force_https)) {
  281. $tmp = preg_replace('/^http:/i', 'https:', $tmp);
  282. }
  283. define('DOL_MAIN_URL_ROOT', $tmp); // URL absolute root (https://sss/dolibarr, ...)
  284. $uri = preg_replace('/^http(s?):\/\//i', '', constant('DOL_MAIN_URL_ROOT')); // $uri contains url without http*
  285. $suburi = strstr($uri, '/'); // $suburi contains url without domain:port
  286. if (empty($suburi) || $suburi === '/') {
  287. $suburi = ''; // If $suburi is null or /, it is now ''
  288. }
  289. if (!defined('DOL_URL_ROOT')) {
  290. define('DOL_URL_ROOT', $suburi); // URL relative root ('', '/dolibarr', ...)
  291. }
  292. //print DOL_MAIN_URL_ROOT.'-'.DOL_URL_ROOT."\n";
  293. // Define prefix MAIN_DB_PREFIX
  294. define('MAIN_DB_PREFIX', $dolibarr_main_db_prefix);
  295. /*
  296. * Define PATH to external libraries
  297. * To use other version than embeded libraries, define here constant to path. Use '' to use include class path autodetect.
  298. */
  299. // Path to root libraries
  300. if (!defined('TCPDF_PATH')) {
  301. define('TCPDF_PATH', (empty($dolibarr_lib_TCPDF_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tecnickcom/tcpdf/' : $dolibarr_lib_TCPDF_PATH.'/');
  302. }
  303. if (!defined('TCPDI_PATH')) {
  304. define('TCPDI_PATH', (empty($dolibarr_lib_TCPDI_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/tcpdi/' : $dolibarr_lib_TCPDI_PATH.'/');
  305. }
  306. if (!defined('NUSOAP_PATH')) {
  307. define('NUSOAP_PATH', (!isset($dolibarr_lib_NUSOAP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/nusoap/lib/' : (empty($dolibarr_lib_NUSOAP_PATH) ? '' : $dolibarr_lib_NUSOAP_PATH.'/'));
  308. }
  309. if (!defined('PHPEXCELNEW_PATH')) {
  310. define('PHPEXCELNEW_PATH', (!isset($dolibarr_lib_PHPEXCELNEW_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/phpoffice/phpspreadsheet/src/PhpSpreadsheet/' : (empty($dolibarr_lib_PHPEXCELNEW_PATH) ? '' : $dolibarr_lib_PHPEXCELNEW_PATH.'/'));
  311. }
  312. if (!defined('ODTPHP_PATH')) {
  313. define('ODTPHP_PATH', (!isset($dolibarr_lib_ODTPHP_PATH)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/' : (empty($dolibarr_lib_ODTPHP_PATH) ? '' : $dolibarr_lib_ODTPHP_PATH.'/'));
  314. }
  315. if (!defined('ODTPHP_PATHTOPCLZIP')) {
  316. define('ODTPHP_PATHTOPCLZIP', (!isset($dolibarr_lib_ODTPHP_PATHTOPCLZIP)) ?DOL_DOCUMENT_ROOT.'/includes/odtphp/zip/pclzip/' : (empty($dolibarr_lib_ODTPHP_PATHTOPCLZIP) ? '' : $dolibarr_lib_ODTPHP_PATHTOPCLZIP.'/'));
  317. }
  318. if (!defined('JS_CKEDITOR')) {
  319. define('JS_CKEDITOR', (!isset($dolibarr_js_CKEDITOR)) ? '' : (empty($dolibarr_js_CKEDITOR) ? '' : $dolibarr_js_CKEDITOR.'/'));
  320. }
  321. if (!defined('JS_JQUERY')) {
  322. define('JS_JQUERY', (!isset($dolibarr_js_JQUERY)) ? '' : (empty($dolibarr_js_JQUERY) ? '' : $dolibarr_js_JQUERY.'/'));
  323. }
  324. if (!defined('JS_JQUERY_UI')) {
  325. define('JS_JQUERY_UI', (!isset($dolibarr_js_JQUERY_UI)) ? '' : (empty($dolibarr_js_JQUERY_UI) ? '' : $dolibarr_js_JQUERY_UI.'/'));
  326. }
  327. // Other required path
  328. if (!defined('DOL_DEFAULT_TTF')) {
  329. define('DOL_DEFAULT_TTF', (!isset($dolibarr_font_DOL_DEFAULT_TTF)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/Aerial.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF) ? '' : $dolibarr_font_DOL_DEFAULT_TTF));
  330. }
  331. if (!defined('DOL_DEFAULT_TTF_BOLD')) {
  332. define('DOL_DEFAULT_TTF_BOLD', (!isset($dolibarr_font_DOL_DEFAULT_TTF_BOLD)) ?DOL_DOCUMENT_ROOT.'/includes/fonts/AerialBd.ttf' : (empty($dolibarr_font_DOL_DEFAULT_TTF_BOLD) ? '' : $dolibarr_font_DOL_DEFAULT_TTF_BOLD));
  333. }
  334. /*
  335. * Include functions
  336. */
  337. // If password is encoded, we decode it. Note: When page is called for install, $dolibarr_main_db_pass may not be defined yet.
  338. if ((!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) || !empty($dolibarr_main_db_encrypted_pass)) {
  339. if (!empty($dolibarr_main_db_pass) && preg_match('/crypted:/i', $dolibarr_main_db_pass)) {
  340. $dolibarr_main_db_pass = preg_replace('/crypted:/i', '', $dolibarr_main_db_pass);
  341. $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_pass);
  342. $dolibarr_main_db_encrypted_pass = $dolibarr_main_db_pass; // We need to set this so we can use it later to know the password was initially crypted
  343. } else {
  344. $dolibarr_main_db_pass = dol_decode($dolibarr_main_db_encrypted_pass);
  345. }
  346. }