Fully responsive globals.php with vertical menu (#2460)
[openemr.git] / interface / globals.php
blobcad76a149a4a10d9e3411575f818bd3b7ed719aa
1 <?php
2 /**
3 * Default values for optional variables that are allowed to be set by callers.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 // Checks if the server's PHP version is compatible with OpenEMR:
13 require_once(dirname(__FILE__) . "/../src/Common/Compatibility/Checker.php");
14 $response = OpenEMR\Common\Compatibility\Checker::checkPhpVersion();
15 if ($response !== true) {
16 die(htmlspecialchars($response));
19 use OpenEMR\Core\Kernel;
20 use Dotenv\Dotenv;
22 // Throw error if the php openssl module is not installed.
23 if (!(extension_loaded('openssl'))) {
24 error_log("OPENEMR ERROR: OpenEMR is not working since the php openssl module is not installed.", 0);
25 die("OpenEMR Error : OpenEMR is not working since the php openssl module is not installed.");
27 // Throw error if the openssl aes-256-cbc cipher is not available.
28 if (!(in_array('aes-256-cbc', openssl_get_cipher_methods()))) {
29 error_log("OPENEMR ERROR: OpenEMR is not working since the openssl aes-256-cbc cipher is not available.", 0);
30 die("OpenEMR Error : OpenEMR is not working since the openssl aes-256-cbc cipher is not available.");
34 //This is to help debug the ssl mysql connection. This will send messages to php log to show if mysql connections have a cipher set up.
35 $GLOBALS['debug_ssl_mysql_connection'] = false;
37 // Unless specified explicitly, apply Auth functions
38 if (!isset($ignoreAuth)) {
39 $ignoreAuth = false;
42 // Same for onsite
43 if (!isset($ignoreAuth_onsite_portal_two)) {
44 $ignoreAuth_onsite_portal_two = false;
47 // Is this windows or non-windows? Create a boolean definition.
48 if (!defined('IS_WINDOWS')) {
49 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
52 // The webserver_root and web_root are now automatically collected.
53 // If not working, can set manually below.
54 // Auto collect the full absolute directory path for openemr.
55 $webserver_root = dirname(dirname(__FILE__));
56 if (IS_WINDOWS) {
57 //convert windows path separators
58 $webserver_root = str_replace("\\", "/", $webserver_root);
61 // Collect the apache server document root (and convert to windows slashes, if needed)
62 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
63 if (IS_WINDOWS) {
64 //convert windows path separators
65 $server_document_root = str_replace("\\", "/", $server_document_root);
68 // Auto collect the relative html path, i.e. what you would type into the web
69 // browser after the server address to get to OpenEMR.
70 // This removes the leading portion of $webserver_root that it has in common with the web server's document
71 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
72 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
73 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
74 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
75 // Ensure web_root starts with a path separator
76 if (preg_match("/^[^\/]/", $web_root)) {
77 $web_root = "/".$web_root;
80 // The webserver_root and web_root are now automatically collected in
81 // real time per above code. If above is not working, can uncomment and
82 // set manually here:
83 // $webserver_root = "/var/www/openemr";
84 // $web_root = "/openemr";
87 // This is the directory that contains site-specific data. Change this
88 // only if you have some reason to.
89 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
91 // The session name names a cookie stored in the browser.
92 // Now that restore_session() is implemented in javaScript, session IDs are
93 // effectively saved in the top level browser window and there is no longer
94 // any need to change the session name for different OpenEMR instances.
95 // On 4/8/17, added cookie_path to improve security when using different
96 // OpenEMR instances on same server to prevent session conflicts; also
97 // modified interface/login/login.php and library/restoreSession.php to be
98 // consistent with this.
99 // Defaults for session.gc_maxlifetime is often too small. You might choose to
100 // adjust it further.
101 if (session_status() === PHP_SESSION_NONE) {
102 // Only can run these when do not have an active session yet
103 // (for example, need to skip this in the portal where the session is already active)
104 ini_set('session.gc_maxlifetime', '14400');
105 ini_set('session.cookie_path', $web_root ? $web_root : '/');
106 session_name("OpenEMR");
108 session_start();
110 // Set the site ID if required. This must be done before any database
111 // access is attempted.
112 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
113 if (!empty($_GET['site'])) {
114 $tmp = $_GET['site'];
115 } else {
116 if (empty($ignoreAuth)) {
117 // mdsupport - Don't die if logout menu link is called from expired session.
118 // Eliminate this code when close method is available for session management.
119 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
120 $GLOBALS['login_screen'] = "login_screen.php";
121 $srcdir = "../library";
122 require_once("$srcdir/auth.inc");
124 die("Site ID is missing from session data!");
127 $tmp = $_SERVER['HTTP_HOST'];
128 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
129 $tmp = "default";
133 // for both REST API and browser access we can't proceed unless we have a valid site id.
134 // since this is user provided content we need to escape the value but we use htmlspecialchars instead
135 // of text() as our helper functions are loaded in later on in this file.
136 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
137 echo "Invalid URL";
138 error_log("Request with site id '". htmlspecialchars($tmp, ENT_NOQUOTES) . "' contains invalid characters.");
139 die();
142 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
143 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
144 session_unset(); // clear session, clean logout
145 if (isset($landingpage) && !empty($landingpage)) {
146 // OpenEMR Patient Portal use
147 header('Location: index.php?site=' . urlencode($tmp));
148 } else {
149 // Main OpenEMR use
150 header('Location: ../login/login.php?site=' . urlencode($tmp)); // Assuming in the interface/main directory
153 exit;
156 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
157 $_SESSION['site_id'] = $tmp;
158 //error_log("Session site ID has been set to '$tmp'"); // debugging
162 // Set the site-specific directory path.
163 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
165 // Set a site-specific uri root path.
166 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
168 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
170 // Collecting the utf8 disable flag from the sqlconf.php file in order
171 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
172 // then set to iso-8859-1.
173 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
174 if (!$disable_utf8_flag) {
175 ini_set('default_charset', 'utf-8');
176 $HTML_CHARSET = "UTF-8";
177 mb_internal_encoding('UTF-8');
178 } else {
179 ini_set('default_charset', 'iso-8859-1');
180 $HTML_CHARSET = "ISO-8859-1";
181 mb_internal_encoding('ISO-8859-1');
184 // Root directory, relative to the webserver root:
185 $GLOBALS['rootdir'] = "$web_root/interface";
186 $rootdir = $GLOBALS['rootdir'];
187 // Absolute path to the source code include and headers file directory (Full path):
188 $GLOBALS['srcdir'] = "$webserver_root/library";
189 // Absolute path to the location of documentroot directory for use with include statements:
190 $GLOBALS['fileroot'] = "$webserver_root";
191 // Absolute path to the location of interface directory for use with include statements:
192 $include_root = "$webserver_root/interface";
193 // Absolute path to the location of documentroot directory for use with include statements:
194 $GLOBALS['webroot'] = $web_root;
196 // Static assets directory, relative to the webserver root.
197 // (it is very likely that this path will be changed in the future))
198 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
200 // Relative images directory, relative to the webserver root.
201 $GLOBALS['images_static_relative'] = "$web_root/public/images";
203 // Static images directory, absolute to the webserver root.
204 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
206 //Composer vendor directory, absolute to the webserver root.
207 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
208 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
209 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
210 $GLOBALS['incdir'] = $include_root;
211 // Location of the login screen file
212 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
214 // Variable set for Eligibility Verification [EDI-271] path
215 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/documents/edi/";
217 // Check necessary writable paths (add them if do not exist)
218 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/gacl')) {
219 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/gacl', 0755, true);
221 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/main')) {
222 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/main', 0755, true);
225 // Set and check that necessary writeable path exist for mPDF tool
226 $GLOBALS['MPDF_WRITE_DIR'] = $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp';
227 if (! is_dir($GLOBALS['MPDF_WRITE_DIR'])) {
228 mkdir($GLOBALS['MPDF_WRITE_DIR'], 0755, true);
231 // Includes composer autoload
232 // Note this also brings in following library files:
233 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
234 // library/formdata.inc.php - Include sanitization/checking functions (for security)
235 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
236 // library/formatting.inc.php - Includes functions for date/time internationalization and formatting
237 // library/date_functions.php - Includes functions for date internationalization
238 // library/validation/validate_core.php - Includes functions for page validation
239 // library/translation.inc.php - Includes translation functions
240 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
242 // Set up csrf token
243 // This is done in cases where it is not yet set for the session
244 // (note this is permanently done for the session in the main_screen.php script)
245 if (empty($_SESSION['csrf_token'])) {
246 $_SESSION['csrf_token'] = createCsrfToken();
250 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
252 * This allows to define a "development" environment which can then load up
253 * different variables and reporting/debugging functionality. Should be used in
254 * development only, not for production
256 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
258 if (file_exists("{$webserver_root}/.env")) {
259 $dotenv = Dotenv::create($webserver_root);
260 $dotenv->load();
263 // @TODO This needs to be broken out to it's own function, but for time's sake
264 // @TODO putting it here until we land on a good place. RD 2017-05-02
266 $twigOptions = [
267 'debug' => false,
270 $twigLoader = new Twig_Loader_Filesystem();
271 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
273 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
274 $twigEnv->addExtension(new Twig_Extension_Debug());
277 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
278 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
279 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
280 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
281 return xl($string);
282 }));
284 /** Twig_Loader */
285 $GLOBALS['twigLoader'] = $twigLoader;
286 /** Twig_Environment */
287 $GLOBALS['twig'] = $twigEnv;
289 // This will open the openemr mysql connection.
290 require_once(dirname(__FILE__) . "/../library/sql.inc");
292 // Include the version file
293 require_once(dirname(__FILE__) . "/../version.php");
295 // The logging level for common/logging/logger.php
296 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
297 // - DEBUG/INFO are great for development
298 // - INFO/WARN/ERROR are great for production
299 // - TRACE is useful when debugging hard to spot bugs
300 $GLOBALS["log_level"] = "OFF";
302 try {
303 /** @var Kernel */
304 $GLOBALS["kernel"] = new Kernel();
305 } catch (\Exception $e) {
306 error_log($e->getMessage());
307 die();
310 // Should Doctrine make use of connection pooling? Database connection pooling is a method
311 // used to keep database connections open so they can be reused by others. (The only reason
312 // to not use connection pooling is if your server has limited resources.)
313 $GLOBALS["doctrine_connection_pooling"] = true;
315 // Defaults for specific applications.
316 $GLOBALS['weight_loss_clinic'] = false;
317 $GLOBALS['ippf_specific'] = false;
319 // Defaults for drugs and products.
320 $GLOBALS['inhouse_pharmacy'] = false;
321 $GLOBALS['sell_non_drug_products'] = 0;
323 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
324 if (!empty($glrow)) {
325 // Collect user specific settings from user_settings table.
327 $gl_user = array();
328 // Collect the user id first
329 $temp_authuserid = '';
330 if (!empty($_SESSION['authUserID'])) {
331 //Set the user id from the session variable
332 $temp_authuserid = $_SESSION['authUserID'];
333 } else {
334 if (!empty($_POST['authUser'])) {
335 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
336 if (!empty($temp_sql_ret['id'])) {
337 //Set the user id from the login variable
338 $temp_authuserid = $temp_sql_ret['id'];
343 if (!empty($temp_authuserid)) {
344 $glres_user = sqlStatement(
345 "SELECT `setting_label`, `setting_value` " .
346 "FROM `user_settings` " .
347 "WHERE `setting_user` = ? " .
348 "AND `setting_label` LIKE 'global:%'",
349 array($temp_authuserid)
351 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
352 //remove global_ prefix from label
353 $row['setting_label'] = substr($row['setting_label'], 7);
354 $gl_user[$iter]=$row;
358 // Set global parameters from the database globals table.
359 // Some parameters require custom handling.
361 $GLOBALS['language_menu_show'] = array();
362 $glres = sqlStatement(
363 "SELECT gl_name, gl_index, gl_value FROM globals " .
364 "ORDER BY gl_name, gl_index"
366 while ($glrow = sqlFetchArray($glres)) {
367 $gl_name = $glrow['gl_name'];
368 $gl_value = $glrow['gl_value'];
369 // Adjust for user specific settings
370 if (!empty($gl_user)) {
371 foreach ($gl_user as $setting) {
372 if ($gl_name == $setting['setting_label']) {
373 $gl_value = $setting['setting_value'];
378 if ($gl_name == 'language_menu_other') {
379 $GLOBALS['language_menu_show'][] = $gl_value;
380 } elseif ($gl_name == 'css_header') {
381 //Escape css file name using 'attr' for security (prevent XSS).
382 $GLOBALS[$gl_name] = $web_root.'/public/themes/'.attr($gl_value).'?v='.$v_js_includes;
383 $css_header = $GLOBALS[$gl_name];
384 $temp_css_theme_name = $gl_value;
385 } elseif ($gl_name == 'weekend_days') {
386 $GLOBALS[$gl_name] = explode(',', $gl_value);
387 } elseif ($gl_name == 'specific_application') {
388 if ($gl_value == '2') {
389 $GLOBALS['ippf_specific'] = true;
390 } elseif ($gl_value == '3') {
391 $GLOBALS['weight_loss_clinic'] = true;
393 } elseif ($gl_name == 'inhouse_pharmacy') {
394 if ($gl_value) {
395 $GLOBALS['inhouse_pharmacy'] = true;
398 if ($gl_value == '2') {
399 $GLOBALS['sell_non_drug_products'] = 1;
400 } elseif ($gl_value == '3') {
401 $GLOBALS['sell_non_drug_products'] = 2;
403 } elseif ($gl_name == 'gbl_time_zone') {
404 // The default PHP time zone is set here if it was specified, and is used
405 // as source data for the MySQL time zone here and in some other places
406 // where MySQL connections are opened.
407 if ($gl_value) {
408 date_default_timezone_set($gl_value);
411 // Synchronize MySQL time zone with PHP time zone.
412 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
413 } else {
414 $GLOBALS[$gl_name] = $gl_value;
418 // Language cleanup stuff.
419 $GLOBALS['language_menu_login'] = false;
420 if ((count($GLOBALS['language_menu_show']) > 1) || $GLOBALS['language_menu_showall']) {
421 $GLOBALS['language_menu_login'] = true;
424 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
425 // that may use this; note this global has been removed from the standard codebase.
426 $GLOBALS['concurrent_layout'] = 3;
428 // Additional logic to override theme name.
429 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
430 $rtl_override = false;
431 if (isset($_SESSION['language_direction'])) {
432 if ($_SESSION['language_direction'] == 'rtl' &&
433 !strpos($GLOBALS['css_header'], 'rtl') ) {
434 // the $css_header_value is set above
435 $rtl_override = true;
437 } elseif (isset($_SESSION['language_choice'])) {
438 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
439 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
440 if ($_SESSION['language_direction'] == 'rtl' &&
441 !strpos($GLOBALS['css_header'], 'rtl')) {
442 // the $css_header_value is set above
443 $rtl_override = true;
445 } else {
446 //$_SESSION['language_direction'] is not set, so will use the default language
447 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
449 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
450 // @todo eliminate 1 SQL query
451 $rtl_override = true;
456 // change theme name, if the override file exists.
457 if ($rtl_override) {
458 // the $css_header_value is set above
459 $new_theme = 'rtl_' . $temp_css_theme_name;
461 // Check file existance
462 if (file_exists($webserver_root.'/public/themes/'.$new_theme)) {
463 //Escape css file name using 'attr' for security (prevent XSS).
464 $GLOBALS['css_header'] = $web_root.'/public/themes/'.attr($new_theme).'?v='.$v_js_includes;
465 $css_header = $GLOBALS['css_header'];
466 } else {
467 // throw a warning if rtl'ed file does not exist.
468 error_log("Missing theme file ".text($webserver_root).'/public/themes/'.text($new_theme));
472 unset($temp_css_theme_name, $new_theme, $rtl_override);
473 // end of RTL section
476 // End of globals table processing.
477 } else {
478 // Temporary stuff to handle the case where the globals table does not
479 // exist yet. This will happen in sql_upgrade.php on upgrading to the
480 // first release containing this table.
481 $GLOBALS['language_menu_login'] = true;
482 $GLOBALS['language_menu_showall'] = true;
483 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
484 $GLOBALS['language_default'] = "English (Standard)";
485 $GLOBALS['translate_layout'] = true;
486 $GLOBALS['translate_lists'] = true;
487 $GLOBALS['translate_gacl_groups'] = true;
488 $GLOBALS['translate_form_titles'] = true;
489 $GLOBALS['translate_document_categories'] = true;
490 $GLOBALS['translate_appt_categories'] = true;
491 $timeout = 7200;
492 $openemr_name = 'OpenEMR';
493 $css_header = "$web_root/public/themes/style_default.css";
494 $GLOBALS['css_header'] = $css_header;
495 $GLOBALS['schedule_start'] = 8;
496 $GLOBALS['schedule_end'] = 17;
497 $GLOBALS['calendar_interval'] = 15;
498 $GLOBALS['phone_country_code'] = '1';
499 $GLOBALS['disable_non_default_groups'] = true;
500 $GLOBALS['ippf_specific'] = false;
503 // If >0 this will enforce a separate PHP session for each top-level
504 // browser window. You must log in separately for each. This is not
505 // thoroughly tested yet and some browsers might have trouble with it,
506 // so make it 0 if you must. Alternatively, you can set it to 2 to be
507 // notified when the session ID changes.
508 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
510 // Theme definition. All this stuff should be moved to CSS.
512 $top_bg_line = ' bgcolor="#dddddd" ';
513 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
514 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
515 // optimal size for the tiny logo is height 43 width 86 px
516 // inside the open emr they will be auto reduced
517 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
518 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
520 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
521 // The height in pixels of the Title bar:
522 $GLOBALS['titleBarHeight'] = 50;
524 // The assistant word, MORE printed next to titles that can be clicked:
525 // Note this label gets translated here via the xl function
526 // -if you don't want it translated, then strip the xl function away
527 $tmore = xl('(More)');
528 // The assistant word, BACK printed next to titles that return to previous screens:
529 // Note this label gets translated here via the xl function
530 // -if you don't want it translated, then strip the xl function away
531 $tback = xl('(Back)');
533 // This is the idle logout function:
534 // if a page has not been refreshed within this many seconds, the interface
535 // will return to the login page
536 if (!empty($special_timeout)) {
537 $timeout = intval($special_timeout);
540 $versionService = new \OpenEMR\Services\VersionService();
541 $version = $versionService->fetch();
543 if (!empty($version)) {
544 //Version tag
545 $patch_appending = "";
546 //Collected below function call to a variable, since unable to directly include
547 // function calls within empty() in php versions < 5.5 .
548 $version_getrealpatch = $version->getRealPatch();
549 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
550 $patch_appending = " (".$version->getRealPatch().")";
553 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
554 $openemr_version .= $version->getTag() . $patch_appending;
555 } else {
556 $openemr_version = xl('Unknown version');
559 $srcdir = $GLOBALS['srcdir'];
560 $login_screen = $GLOBALS['login_screen'];
561 $GLOBALS['backpic'] = $backpic;
563 // 1 = send email message to given id for Emergency Login user activation,
564 // else 0.
565 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
567 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
568 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
569 //functions, tables for de-identification(Mysql root user and password is required for successful
570 //execution of the de-identification upgrade script)
571 $GLOBALS['include_de_identification']=0;
572 // Include the authentication module code here, but the rule is
573 // if the file has the word "login" in the source code file name,
574 // don't include the authentication module - we do this to avoid
575 // include loops.
577 if (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
578 $ignoreAuth = true;
581 if (!$ignoreAuth) {
582 require_once("$srcdir/auth.inc");
586 // This is the background color to apply to form fields that are searchable.
587 // Currently it is applicable only to the "Search or Add Patient" form.
588 $GLOBALS['layout_search_color'] = '#ff9919';
590 //EMAIL SETTINGS
591 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
594 //module configurations
595 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
596 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
597 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
599 // Don't change anything below this line. ////////////////////////////
601 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
603 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
604 $_SESSION['pid'] = $_GET['pid'];
605 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
606 $_SESSION['pid'] = $_POST['pid'];
609 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
610 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
611 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
613 //This is crucial for therapy groups and patients mechanisms to work together properly
614 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
615 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
617 // global interface function to format text length using ellipses
618 function strterm($string, $length)
620 if (strlen($string) >= ($length-3)) {
621 return substr($string, 0, $length-3) . "...";
622 } else {
623 return $string;
627 // Override temporary_files_dir
628 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
630 // turn off PHP compatibility warnings
631 ini_set("session.bug_compat_warn", "off");
632 // user debug mode
633 if ((int) $GLOBALS['user_debug'] > 1) {
634 error_reporting(error_reporting() & ~E_WARNING & ~E_NOTICE & ~E_USER_WARNING);
635 ini_set('display_errors', 1);