3 * Default values for optional variables that are allowed to be set by callers.
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @author Rod Roark <rod@sunsetsystems.com>
9 * @copyright Copyright (c) 2018-2019 Brady Miller <brady.g.miller@gmail.com>
10 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
13 // Checks if the server's PHP version is compatible with OpenEMR:
14 require_once(dirname(__FILE__
) . "/../src/Common/Compatibility/Checker.php");
15 $response = OpenEMR\Common\Compatibility\Checker
::checkPhpVersion();
16 if ($response !== true) {
17 die(htmlspecialchars($response));
20 use OpenEMR\Core\Kernel
;
21 use OpenEMR\Core\ModulesApplication
;
24 // Throw error if the php openssl module is not installed.
25 if (!(extension_loaded('openssl'))) {
26 error_log("OPENEMR ERROR: OpenEMR is not working since the php openssl module is not installed.", 0);
27 die("OpenEMR Error : OpenEMR is not working since the php openssl module is not installed.");
29 // Throw error if the openssl aes-256-cbc cipher is not available.
30 if (!(in_array('aes-256-cbc', openssl_get_cipher_methods()))) {
31 error_log("OPENEMR ERROR: OpenEMR is not working since the openssl aes-256-cbc cipher is not available.", 0);
32 die("OpenEMR Error : OpenEMR is not working since the openssl aes-256-cbc cipher is not available.");
36 //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.
37 $GLOBALS['debug_ssl_mysql_connection'] = false;
39 // Unless specified explicitly, apply Auth functions
40 if (!isset($ignoreAuth)) {
45 if (!isset($ignoreAuth_onsite_portal_two)) {
46 $ignoreAuth_onsite_portal_two = false;
49 // Is this windows or non-windows? Create a boolean definition.
50 if (!defined('IS_WINDOWS')) {
51 define('IS_WINDOWS', (stripos(PHP_OS
, 'WIN') === 0));
54 // The webserver_root and web_root are now automatically collected.
55 // If not working, can set manually below.
56 // Auto collect the full absolute directory path for openemr.
57 $webserver_root = dirname(dirname(__FILE__
));
59 //convert windows path separators
60 $webserver_root = str_replace("\\", "/", $webserver_root);
63 // Collect the apache server document root (and convert to windows slashes, if needed)
64 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
66 //convert windows path separators
67 $server_document_root = str_replace("\\", "/", $server_document_root);
70 // Auto collect the relative html path, i.e. what you would type into the web
71 // browser after the server address to get to OpenEMR.
72 // This removes the leading portion of $webserver_root that it has in common with the web server's document
73 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
74 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
75 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
76 $web_root = substr($webserver_root, strspn($webserver_root ^
$server_document_root, "\0"));
77 // Ensure web_root starts with a path separator
78 if (preg_match("/^[^\/]/", $web_root)) {
79 $web_root = "/".$web_root;
82 // The webserver_root and web_root are now automatically collected in
83 // real time per above code. If above is not working, can uncomment and
85 // $webserver_root = "/var/www/openemr";
86 // $web_root = "/openemr";
89 // This is the directory that contains site-specific data. Change this
90 // only if you have some reason to.
91 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
93 // If a session does not yet exist, then will start the core OpenEMR session.
94 // If a session already exists, then this means portal is being used, which
95 // has already created a portal session/cookie, so will bypass setting of
96 // the core OpenEMR session/cookie.
97 if (session_status() === PHP_SESSION_NONE
) {
98 require_once(dirname(__FILE__
) . "/../src/Common/Session/SessionUtil.php");
99 OpenEMR\Common\Session\SessionUtil
::coreSessionStart($web_root);
102 // Set the site ID if required. This must be done before any database
103 // access is attempted.
104 if (empty($_SESSION['site_id']) ||
!empty($_GET['site'])) {
105 if (!empty($_GET['site'])) {
106 $tmp = $_GET['site'];
108 if (empty($ignoreAuth)) {
109 // mdsupport - Don't die if logout menu link is called from expired session.
110 // Eliminate this code when close method is available for session management.
111 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
112 $GLOBALS['login_screen'] = "login_screen.php";
113 $srcdir = "../library";
114 require_once("$srcdir/auth.inc");
116 die("Site ID is missing from session data!");
119 $tmp = $_SERVER['HTTP_HOST'];
120 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
125 // for both REST API and browser access we can't proceed unless we have a valid site id.
126 // since this is user provided content we need to escape the value but we use htmlspecialchars instead
127 // of text() as our helper functions are loaded in later on in this file.
128 if (empty($tmp) ||
preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
130 error_log("Request with site id '". htmlspecialchars($tmp, ENT_QUOTES
) . "' contains invalid characters.");
134 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
135 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
136 session_unset(); // clear session, clean logout
137 if (isset($landingpage) && !empty($landingpage)) {
138 // OpenEMR Patient Portal use
139 header('Location: index.php?site=' . urlencode($tmp));
142 header('Location: ../login/login.php?site=' . urlencode($tmp)); // Assuming in the interface/main directory
148 if (!isset($_SESSION['site_id']) ||
$_SESSION['site_id'] != $tmp) {
149 $_SESSION['site_id'] = $tmp;
150 //error_log("Session site ID has been set to '$tmp'"); // debugging
154 // Set the site-specific directory path.
155 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
157 // Set a site-specific uri root path.
158 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
160 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
162 // Collecting the utf8 disable flag from the sqlconf.php file in order
163 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
164 // then set to iso-8859-1.
165 require_once(dirname(__FILE__
) . "/../library/sqlconf.php");
166 if (!$disable_utf8_flag) {
167 ini_set('default_charset', 'utf-8');
168 $HTML_CHARSET = "UTF-8";
169 mb_internal_encoding('UTF-8');
171 ini_set('default_charset', 'iso-8859-1');
172 $HTML_CHARSET = "ISO-8859-1";
173 mb_internal_encoding('ISO-8859-1');
176 // Root directory, relative to the webserver root:
177 $GLOBALS['rootdir'] = "$web_root/interface";
178 $rootdir = $GLOBALS['rootdir'];
179 // Absolute path to the source code include and headers file directory (Full path):
180 $GLOBALS['srcdir'] = "$webserver_root/library";
181 // Absolute path to the location of documentroot directory for use with include statements:
182 $GLOBALS['fileroot'] = "$webserver_root";
183 // Absolute path to the location of interface directory for use with include statements:
184 $include_root = "$webserver_root/interface";
185 // Absolute path to the location of documentroot directory for use with include statements:
186 $GLOBALS['webroot'] = $web_root;
188 // Static assets directory, relative to the webserver root.
189 // (it is very likely that this path will be changed in the future))
190 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
192 // Relative images directory, relative to the webserver root.
193 $GLOBALS['images_static_relative'] = "$web_root/public/images";
195 // Static images directory, absolute to the webserver root.
196 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
198 //Composer vendor directory, absolute to the webserver root.
199 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
200 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
201 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
202 $GLOBALS['incdir'] = $include_root;
203 // Location of the login screen file
204 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
206 // Variable set for Eligibility Verification [EDI-271] path
207 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/documents/edi/";
209 // Check necessary writable paths (add them if do not exist)
210 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/gacl')) {
211 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/gacl', 0755, true);
213 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/main')) {
214 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/main', 0755, true);
217 // Set and check that necessary writeable path exist for mPDF tool
218 $GLOBALS['MPDF_WRITE_DIR'] = $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp';
219 if (! is_dir($GLOBALS['MPDF_WRITE_DIR'])) {
220 mkdir($GLOBALS['MPDF_WRITE_DIR'], 0755, true);
223 // Includes composer autoload
224 // Note this also brings in following library files:
225 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
226 // library/formdata.inc.php - Include sanitization/checking functions (for security)
227 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
228 // library/formatting.inc.php - Includes functions for date/time internationalization and formatting
229 // library/date_functions.php - Includes functions for date internationalization
230 // library/validation/validate_core.php - Includes functions for page validation
231 // library/translation.inc.php - Includes translation functions
232 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
235 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
237 * This allows to define a "development" environment which can then load up
238 * different variables and reporting/debugging functionality. Should be used in
239 * development only, not for production
241 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
243 if (file_exists("{$webserver_root}/.env")) {
244 $dotenv = Dotenv
::create($webserver_root);
248 // This will open the openemr mysql connection.
249 require_once(dirname(__FILE__
) . "/../library/sql.inc");
251 // Include the version file
252 require_once(dirname(__FILE__
) . "/../version.php");
254 // The logging level for common/logging/logger.php
255 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
256 // - DEBUG/INFO are great for development
257 // - INFO/WARN/ERROR are great for production
258 // - TRACE is useful when debugging hard to spot bugs
259 $GLOBALS["log_level"] = "OFF";
261 // @TODO This needs to be broken out to it's own function, but for time's sake
262 // @TODO putting it here until we land on a good place. RD 2017-05-02
266 $twigLoader = new Twig_Loader_Filesystem();
267 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
268 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
269 $twigEnv->addExtension(new Twig_Extension_Debug());
271 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
272 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
273 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
274 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
278 $GLOBALS['twigLoader'] = $twigLoader;
279 /** Twig_Environment */
280 $GLOBALS['twig'] = $twigEnv;
284 $GLOBALS["kernel"] = new Kernel();
285 } catch (\Exception
$e) {
286 error_log(errorLogEscape($e->getMessage()));
290 // Should Doctrine make use of connection pooling? Database connection pooling is a method
291 // used to keep database connections open so they can be reused by others. (The only reason
292 // to not use connection pooling is if your server has limited resources.)
293 $GLOBALS["doctrine_connection_pooling"] = true;
295 // Defaults for specific applications.
296 $GLOBALS['weight_loss_clinic'] = false;
297 $GLOBALS['ippf_specific'] = false;
299 // Defaults for drugs and products.
300 $GLOBALS['inhouse_pharmacy'] = false;
301 $GLOBALS['sell_non_drug_products'] = 0;
303 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
304 if (!empty($glrow)) {
305 // Collect user specific settings from user_settings table.
308 // Collect the user id first
309 $temp_authuserid = '';
310 if (!empty($_SESSION['authUserID'])) {
311 //Set the user id from the session variable
312 $temp_authuserid = $_SESSION['authUserID'];
314 if (!empty($_POST['authUser'])) {
315 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
316 if (!empty($temp_sql_ret['id'])) {
317 //Set the user id from the login variable
318 $temp_authuserid = $temp_sql_ret['id'];
323 if (!empty($temp_authuserid)) {
324 $glres_user = sqlStatement(
325 "SELECT `setting_label`, `setting_value` " .
326 "FROM `user_settings` " .
327 "WHERE `setting_user` = ? " .
328 "AND `setting_label` LIKE 'global:%'",
329 array($temp_authuserid)
331 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++
) {
332 //remove global_ prefix from label
333 $row['setting_label'] = substr($row['setting_label'], 7);
334 $gl_user[$iter]=$row;
338 // Set global parameters from the database globals table.
339 // Some parameters require custom handling.
341 $GLOBALS['language_menu_show'] = array();
342 $glres = sqlStatement(
343 "SELECT gl_name, gl_index, gl_value FROM globals " .
344 "ORDER BY gl_name, gl_index"
346 while ($glrow = sqlFetchArray($glres)) {
347 $gl_name = $glrow['gl_name'];
348 $gl_value = $glrow['gl_value'];
349 // Adjust for user specific settings
350 if (!empty($gl_user)) {
351 foreach ($gl_user as $setting) {
352 if ($gl_name == $setting['setting_label']) {
353 $gl_value = $setting['setting_value'];
358 if ($gl_name == 'language_menu_other') {
359 $GLOBALS['language_menu_show'][] = $gl_value;
360 } elseif ($gl_name == 'css_header') {
361 //Escape css file name using 'attr' for security (prevent XSS).
362 $GLOBALS[$gl_name] = $web_root.'/public/themes/'.attr($gl_value).'?v='.$v_js_includes;
363 $css_header = $GLOBALS[$gl_name];
364 $temp_css_theme_name = $gl_value;
365 } elseif ($gl_name == 'weekend_days') {
366 $GLOBALS[$gl_name] = explode(',', $gl_value);
367 } elseif ($gl_name == 'specific_application') {
368 if ($gl_value == '2') {
369 $GLOBALS['ippf_specific'] = true;
370 } elseif ($gl_value == '3') {
371 $GLOBALS['weight_loss_clinic'] = true;
373 } elseif ($gl_name == 'inhouse_pharmacy') {
375 $GLOBALS['inhouse_pharmacy'] = true;
378 if ($gl_value == '2') {
379 $GLOBALS['sell_non_drug_products'] = 1;
380 } elseif ($gl_value == '3') {
381 $GLOBALS['sell_non_drug_products'] = 2;
383 } elseif ($gl_name == 'gbl_time_zone') {
384 // The default PHP time zone is set here if it was specified, and is used
385 // as source data for the MySQL time zone here and in some other places
386 // where MySQL connections are opened.
388 date_default_timezone_set($gl_value);
391 // Synchronize MySQL time zone with PHP time zone.
392 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
394 $GLOBALS[$gl_name] = $gl_value;
398 // Language cleanup stuff.
399 $GLOBALS['language_menu_login'] = false;
400 if ((count($GLOBALS['language_menu_show']) > 1) ||
$GLOBALS['language_menu_showall']) {
401 $GLOBALS['language_menu_login'] = true;
404 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
405 // that may use this; note this global has been removed from the standard codebase.
406 $GLOBALS['concurrent_layout'] = 3;
408 // Additional logic to override theme name.
409 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
410 $rtl_override = false;
411 if (isset($_SESSION['language_direction'])) {
412 if ($_SESSION['language_direction'] == 'rtl' &&
413 !strpos($GLOBALS['css_header'], 'rtl') ) {
414 // the $css_header_value is set above
415 $rtl_override = true;
417 } elseif (isset($_SESSION['language_choice'])) {
418 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
419 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
420 if ($_SESSION['language_direction'] == 'rtl' &&
421 !strpos($GLOBALS['css_header'], 'rtl')) {
422 // the $css_header_value is set above
423 $rtl_override = true;
426 //$_SESSION['language_direction'] is not set, so will use the default language
427 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
429 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
430 // @todo eliminate 1 SQL query
431 $rtl_override = true;
436 // change theme name, if the override file exists.
438 // the $css_header_value is set above
439 $new_theme = 'rtl_' . $temp_css_theme_name;
441 // Check file existance
442 if (file_exists($webserver_root.'/public/themes/'.$new_theme)) {
443 //Escape css file name using 'attr' for security (prevent XSS).
444 $GLOBALS['css_header'] = $web_root.'/public/themes/'.attr($new_theme).'?v='.$v_js_includes;
445 $css_header = $GLOBALS['css_header'];
447 // throw a warning if rtl'ed file does not exist.
448 error_log("Missing theme file " . errorLogEscape($webserver_root) . '/public/themes/' . errorLogEscape($new_theme));
452 unset($temp_css_theme_name, $new_theme, $rtl_override);
453 // end of RTL section
456 // End of globals table processing.
458 // Temporary stuff to handle the case where the globals table does not
459 // exist yet. This will happen in sql_upgrade.php on upgrading to the
460 // first release containing this table.
461 $GLOBALS['language_menu_login'] = true;
462 $GLOBALS['language_menu_showall'] = true;
463 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
464 $GLOBALS['language_default'] = "English (Standard)";
465 $GLOBALS['translate_layout'] = true;
466 $GLOBALS['translate_lists'] = true;
467 $GLOBALS['translate_gacl_groups'] = true;
468 $GLOBALS['translate_form_titles'] = true;
469 $GLOBALS['translate_document_categories'] = true;
470 $GLOBALS['translate_appt_categories'] = true;
472 $openemr_name = 'OpenEMR';
473 $css_header = "$web_root/public/themes/style_default.css";
474 $GLOBALS['css_header'] = $css_header;
475 $GLOBALS['schedule_start'] = 8;
476 $GLOBALS['schedule_end'] = 17;
477 $GLOBALS['calendar_interval'] = 15;
478 $GLOBALS['phone_country_code'] = '1';
479 $GLOBALS['disable_non_default_groups'] = true;
480 $GLOBALS['ippf_specific'] = false;
483 // If >0 this will enforce a separate PHP session for each top-level
484 // browser window. You must log in separately for each. This is not
485 // thoroughly tested yet and some browsers might have trouble with it,
486 // so make it 0 if you must. Alternatively, you can set it to 2 to be
487 // notified when the session ID changes.
488 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
490 // Theme definition. All this stuff should be moved to CSS.
492 $top_bg_line = ' bgcolor="#dddddd" ';
493 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
494 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
495 // optimal size for the tiny logo is height 43 width 86 px
496 // inside the open emr they will be auto reduced
497 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
498 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
500 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
501 // The height in pixels of the Title bar:
502 $GLOBALS['titleBarHeight'] = 50;
504 // The assistant word, MORE printed next to titles that can be clicked:
505 // Note this label gets translated here via the xl function
506 // -if you don't want it translated, then strip the xl function away
507 $tmore = xl('(More)');
508 // The assistant word, BACK printed next to titles that return to previous screens:
509 // Note this label gets translated here via the xl function
510 // -if you don't want it translated, then strip the xl function away
511 $tback = xl('(Back)');
513 // This is the idle logout function:
514 // if a page has not been refreshed within this many seconds, the interface
515 // will return to the login page
516 if (!empty($special_timeout)) {
517 $timeout = intval($special_timeout);
520 $versionService = new \OpenEMR\Services\
VersionService();
521 $version = $versionService->fetch();
523 if (!empty($version)) {
525 $patch_appending = "";
526 //Collected below function call to a variable, since unable to directly include
527 // function calls within empty() in php versions < 5.5 .
528 $version_getrealpatch = $version->getRealPatch();
529 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
530 $patch_appending = " (".$version->getRealPatch().")";
533 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
534 $openemr_version .= $version->getTag() . $patch_appending;
536 $openemr_version = xl('Unknown version');
539 $srcdir = $GLOBALS['srcdir'];
540 $login_screen = $GLOBALS['login_screen'];
541 $GLOBALS['backpic'] = $backpic;
543 // 1 = send email message to given id for Emergency Login user activation,
545 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ?
0 : 1;
547 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
548 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
549 //functions, tables for de-identification(Mysql root user and password is required for successful
550 //execution of the de-identification upgrade script)
551 $GLOBALS['include_de_identification']=0;
552 // Include the authentication module code here, but the rule is
553 // if the file has the word "login" in the source code file name,
554 // don't include the authentication module - we do this to avoid
557 if (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
562 require_once("$srcdir/auth.inc");
566 // This is the background color to apply to form fields that are searchable.
567 // Currently it is applicable only to the "Search or Add Patient" form.
568 $GLOBALS['layout_search_color'] = '#ff9919';
571 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
574 //module configurations
575 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
576 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
577 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
580 // load up the modules system and bootstrap them.
581 // This has to be fast, so any modules that tie into the bootstrap must be kept lightweight
582 // registering event listeners, etc.
583 // TODO: why do we have 3 different directories we need to pass in for the zend dir path. shouldn't zendModDir already have all the paths set up?
584 /** @var ModulesApplication */
585 $GLOBALS['modules_application'] = new ModulesApplication(
587 $GLOBALS['fileroot'],
588 $GLOBALS['baseModDir'],
589 $GLOBALS['zendModDir']
591 } catch (\Exception
$ex) {
592 error_log(errorLogEscape($ex->getMessage() . $ex->getTraceAsString()));
596 // Don't change anything below this line. ////////////////////////////
598 $encounter = empty($_SESSION['encounter']) ?
0 : $_SESSION['encounter'];
600 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
601 $_SESSION['pid'] = $_GET['pid'];
602 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
603 $_SESSION['pid'] = $_POST['pid'];
606 $pid = empty($_SESSION['pid']) ?
0 : $_SESSION['pid'];
607 $userauthorized = empty($_SESSION['userauthorized']) ?
0 : $_SESSION['userauthorized'];
608 $groupname = empty($_SESSION['authProvider']) ?
0 : $_SESSION['authProvider'];
610 //This is crucial for therapy groups and patients mechanisms to work together properly
611 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ?
'gid' : 'pid';
612 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ?
$_SESSION['therapy_group'] : 0;
614 // global interface function to format text length using ellipses
615 function strterm($string, $length)
617 if (strlen($string) >= ($length-3)) {
618 return substr($string, 0, $length-3) . "...";
624 // Check if the current or a specified user logs in with LDAP.
625 function useActiveDirectory($user = '')
627 if (empty($GLOBALS['gbl_ldap_enabled'])) {
631 $user = $_SESSION['authUser'];
633 $exarr = explode(',', $GLOBALS['gbl_ldap_exclusions']);
634 foreach ($exarr as $ex) {
635 if ($user == trim($ex)) {
642 // Override temporary_files_dir
643 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
645 // turn off PHP compatibility warnings
646 ini_set("session.bug_compat_warn", "off");
648 if ((int) $GLOBALS['user_debug'] > 1) {
649 error_reporting(error_reporting() & ~E_WARNING
& ~E_NOTICE
& ~E_USER_WARNING
);
650 ini_set('display_errors', 1);