Update X12_5010_837P.php (#2599)
[openemr.git] / interface / globals.php
blob36c86c89ce65c33c532957008f08c00da1cbe5b2
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-2019 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 OpenEMR\Core\ModulesApplication;
21 use Dotenv\Dotenv;
23 // Throw error if the php openssl module is not installed.
24 if (!(extension_loaded('openssl'))) {
25 error_log("OPENEMR ERROR: OpenEMR is not working since the php openssl module is not installed.", 0);
26 die("OpenEMR Error : OpenEMR is not working since the php openssl module is not installed.");
28 // Throw error if the openssl aes-256-cbc cipher is not available.
29 if (!(in_array('aes-256-cbc', openssl_get_cipher_methods()))) {
30 error_log("OPENEMR ERROR: OpenEMR is not working since the openssl aes-256-cbc cipher is not available.", 0);
31 die("OpenEMR Error : OpenEMR is not working since the openssl aes-256-cbc cipher is not available.");
35 //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.
36 $GLOBALS['debug_ssl_mysql_connection'] = false;
38 // Unless specified explicitly, apply Auth functions
39 if (!isset($ignoreAuth)) {
40 $ignoreAuth = false;
43 // Same for onsite
44 if (!isset($ignoreAuth_onsite_portal_two)) {
45 $ignoreAuth_onsite_portal_two = false;
48 // Is this windows or non-windows? Create a boolean definition.
49 if (!defined('IS_WINDOWS')) {
50 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
53 // The webserver_root and web_root are now automatically collected.
54 // If not working, can set manually below.
55 // Auto collect the full absolute directory path for openemr.
56 $webserver_root = dirname(dirname(__FILE__));
57 if (IS_WINDOWS) {
58 //convert windows path separators
59 $webserver_root = str_replace("\\", "/", $webserver_root);
62 // Collect the apache server document root (and convert to windows slashes, if needed)
63 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
64 if (IS_WINDOWS) {
65 //convert windows path separators
66 $server_document_root = str_replace("\\", "/", $server_document_root);
69 // Auto collect the relative html path, i.e. what you would type into the web
70 // browser after the server address to get to OpenEMR.
71 // This removes the leading portion of $webserver_root that it has in common with the web server's document
72 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
73 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
74 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
75 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
76 // Ensure web_root starts with a path separator
77 if (preg_match("/^[^\/]/", $web_root)) {
78 $web_root = "/".$web_root;
81 // The webserver_root and web_root are now automatically collected in
82 // real time per above code. If above is not working, can uncomment and
83 // set manually here:
84 // $webserver_root = "/var/www/openemr";
85 // $web_root = "/openemr";
88 // This is the directory that contains site-specific data. Change this
89 // only if you have some reason to.
90 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
92 // If a session does not yet exist, then will start the core OpenEMR session.
93 // If a session already exists, then this means portal is being used, which
94 // has already created a portal session/cookie, so will bypass setting of
95 // the core OpenEMR session/cookie.
96 if (session_status() === PHP_SESSION_NONE) {
97 require_once(dirname(__FILE__) . "/../src/Common/Session/SessionUtil.php");
98 OpenEMR\Common\Session\SessionUtil::coreSessionStart($web_root);
101 // Set the site ID if required. This must be done before any database
102 // access is attempted.
103 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
104 if (!empty($_GET['site'])) {
105 $tmp = $_GET['site'];
106 } else {
107 if (empty($ignoreAuth)) {
108 // mdsupport - Don't die if logout menu link is called from expired session.
109 // Eliminate this code when close method is available for session management.
110 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
111 $GLOBALS['login_screen'] = "login_screen.php";
112 $srcdir = "../library";
113 require_once("$srcdir/auth.inc");
115 die("Site ID is missing from session data!");
118 $tmp = $_SERVER['HTTP_HOST'];
119 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
120 $tmp = "default";
124 // for both REST API and browser access we can't proceed unless we have a valid site id.
125 // since this is user provided content we need to escape the value but we use htmlspecialchars instead
126 // of text() as our helper functions are loaded in later on in this file.
127 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
128 echo "Invalid URL";
129 error_log("Request with site id '". htmlspecialchars($tmp, ENT_QUOTES) . "' contains invalid characters.");
130 die();
133 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
134 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
135 session_unset(); // clear session, clean logout
136 if (isset($landingpage) && !empty($landingpage)) {
137 // OpenEMR Patient Portal use
138 header('Location: index.php?site=' . urlencode($tmp));
139 } else {
140 // Main OpenEMR use
141 header('Location: ../login/login.php?site=' . urlencode($tmp)); // Assuming in the interface/main directory
144 exit;
147 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
148 $_SESSION['site_id'] = $tmp;
149 //error_log("Session site ID has been set to '$tmp'"); // debugging
153 // Set the site-specific directory path.
154 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
156 // Set a site-specific uri root path.
157 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
159 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
161 // Collecting the utf8 disable flag from the sqlconf.php file in order
162 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
163 // then set to iso-8859-1.
164 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
165 if (!$disable_utf8_flag) {
166 ini_set('default_charset', 'utf-8');
167 $HTML_CHARSET = "UTF-8";
168 mb_internal_encoding('UTF-8');
169 } else {
170 ini_set('default_charset', 'iso-8859-1');
171 $HTML_CHARSET = "ISO-8859-1";
172 mb_internal_encoding('ISO-8859-1');
175 // Root directory, relative to the webserver root:
176 $GLOBALS['rootdir'] = "$web_root/interface";
177 $rootdir = $GLOBALS['rootdir'];
178 // Absolute path to the source code include and headers file directory (Full path):
179 $GLOBALS['srcdir'] = "$webserver_root/library";
180 // Absolute path to the location of documentroot directory for use with include statements:
181 $GLOBALS['fileroot'] = "$webserver_root";
182 // Absolute path to the location of interface directory for use with include statements:
183 $include_root = "$webserver_root/interface";
184 // Absolute path to the location of documentroot directory for use with include statements:
185 $GLOBALS['webroot'] = $web_root;
187 // Static assets directory, relative to the webserver root.
188 // (it is very likely that this path will be changed in the future))
189 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
191 // Relative images directory, relative to the webserver root.
192 $GLOBALS['images_static_relative'] = "$web_root/public/images";
194 // Static images directory, absolute to the webserver root.
195 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
197 //Composer vendor directory, absolute to the webserver root.
198 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
199 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
200 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
201 $GLOBALS['incdir'] = $include_root;
202 // Location of the login screen file
203 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
205 // Variable set for Eligibility Verification [EDI-271] path
206 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/documents/edi/";
208 // Check necessary writable paths (add them if do not exist)
209 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/gacl')) {
210 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/gacl', 0755, true);
212 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/main')) {
213 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/smarty/main', 0755, true);
216 // Set and check that necessary writeable path exist for mPDF tool
217 $GLOBALS['MPDF_WRITE_DIR'] = $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp';
218 if (! is_dir($GLOBALS['MPDF_WRITE_DIR'])) {
219 mkdir($GLOBALS['MPDF_WRITE_DIR'], 0755, true);
222 // Includes composer autoload
223 // Note this also brings in following library files:
224 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
225 // library/formdata.inc.php - Include sanitization/checking functions (for security)
226 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
227 // library/formatting.inc.php - Includes functions for date/time internationalization and formatting
228 // library/date_functions.php - Includes functions for date internationalization
229 // library/validation/validate_core.php - Includes functions for page validation
230 // library/translation.inc.php - Includes translation functions
231 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
234 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
236 * This allows to define a "development" environment which can then load up
237 * different variables and reporting/debugging functionality. Should be used in
238 * development only, not for production
240 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
242 if (file_exists("{$webserver_root}/.env")) {
243 $dotenv = Dotenv::create($webserver_root);
244 $dotenv->load();
247 // This will open the openemr mysql connection.
248 require_once(dirname(__FILE__) . "/../library/sql.inc");
250 // Include the version file
251 require_once(dirname(__FILE__) . "/../version.php");
253 // The logging level for common/logging/logger.php
254 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
255 // - DEBUG/INFO are great for development
256 // - INFO/WARN/ERROR are great for production
257 // - TRACE is useful when debugging hard to spot bugs
258 $GLOBALS["log_level"] = "OFF";
260 try {
261 /** @var Kernel */
262 $GLOBALS["kernel"] = new Kernel();
263 } catch (\Exception $e) {
264 error_log(errorLogEscape($e->getMessage()));
265 die();
268 // Should Doctrine make use of connection pooling? Database connection pooling is a method
269 // used to keep database connections open so they can be reused by others. (The only reason
270 // to not use connection pooling is if your server has limited resources.)
271 $GLOBALS["doctrine_connection_pooling"] = true;
273 // Defaults for specific applications.
274 $GLOBALS['weight_loss_clinic'] = false;
275 $GLOBALS['ippf_specific'] = false;
277 // Defaults for drugs and products.
278 $GLOBALS['inhouse_pharmacy'] = false;
279 $GLOBALS['sell_non_drug_products'] = 0;
281 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
282 if (!empty($glrow)) {
283 // Collect user specific settings from user_settings table.
285 $gl_user = array();
286 // Collect the user id first
287 $temp_authuserid = '';
288 if (!empty($_SESSION['authUserID'])) {
289 //Set the user id from the session variable
290 $temp_authuserid = $_SESSION['authUserID'];
291 } else {
292 if (!empty($_POST['authUser'])) {
293 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
294 if (!empty($temp_sql_ret['id'])) {
295 //Set the user id from the login variable
296 $temp_authuserid = $temp_sql_ret['id'];
301 if (!empty($temp_authuserid)) {
302 $glres_user = sqlStatement(
303 "SELECT `setting_label`, `setting_value` " .
304 "FROM `user_settings` " .
305 "WHERE `setting_user` = ? " .
306 "AND `setting_label` LIKE 'global:%'",
307 array($temp_authuserid)
309 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
310 //remove global_ prefix from label
311 $row['setting_label'] = substr($row['setting_label'], 7);
312 $gl_user[$iter]=$row;
316 // Set global parameters from the database globals table.
317 // Some parameters require custom handling.
319 $GLOBALS['language_menu_show'] = array();
320 $glres = sqlStatement(
321 "SELECT gl_name, gl_index, gl_value FROM globals " .
322 "ORDER BY gl_name, gl_index"
324 while ($glrow = sqlFetchArray($glres)) {
325 $gl_name = $glrow['gl_name'];
326 $gl_value = $glrow['gl_value'];
327 // Adjust for user specific settings
328 if (!empty($gl_user)) {
329 foreach ($gl_user as $setting) {
330 if ($gl_name == $setting['setting_label']) {
331 $gl_value = $setting['setting_value'];
336 if ($gl_name == 'language_menu_other') {
337 $GLOBALS['language_menu_show'][] = $gl_value;
338 } elseif ($gl_name == 'css_header') {
339 //Escape css file name using 'attr' for security (prevent XSS).
340 $GLOBALS[$gl_name] = $web_root.'/public/themes/'.attr($gl_value).'?v='.$v_js_includes;
341 $css_header = $GLOBALS[$gl_name];
342 $temp_css_theme_name = $gl_value;
343 } elseif ($gl_name == 'weekend_days') {
344 $GLOBALS[$gl_name] = explode(',', $gl_value);
345 } elseif ($gl_name == 'specific_application') {
346 if ($gl_value == '2') {
347 $GLOBALS['ippf_specific'] = true;
348 } elseif ($gl_value == '3') {
349 $GLOBALS['weight_loss_clinic'] = true;
351 } elseif ($gl_name == 'inhouse_pharmacy') {
352 if ($gl_value) {
353 $GLOBALS['inhouse_pharmacy'] = true;
356 if ($gl_value == '2') {
357 $GLOBALS['sell_non_drug_products'] = 1;
358 } elseif ($gl_value == '3') {
359 $GLOBALS['sell_non_drug_products'] = 2;
361 } elseif ($gl_name == 'gbl_time_zone') {
362 // The default PHP time zone is set here if it was specified, and is used
363 // as source data for the MySQL time zone here and in some other places
364 // where MySQL connections are opened.
365 if ($gl_value) {
366 date_default_timezone_set($gl_value);
369 // Synchronize MySQL time zone with PHP time zone.
370 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
371 } else {
372 $GLOBALS[$gl_name] = $gl_value;
376 // Language cleanup stuff.
377 $GLOBALS['language_menu_login'] = false;
378 if ((count($GLOBALS['language_menu_show']) > 1) || $GLOBALS['language_menu_showall']) {
379 $GLOBALS['language_menu_login'] = true;
382 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
383 // that may use this; note this global has been removed from the standard codebase.
384 $GLOBALS['concurrent_layout'] = 3;
386 // Additional logic to override theme name.
387 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
388 $rtl_override = false;
389 if (isset($_SESSION['language_direction'])) {
390 if ($_SESSION['language_direction'] == 'rtl' &&
391 !strpos($GLOBALS['css_header'], 'rtl') ) {
392 // the $css_header_value is set above
393 $rtl_override = true;
395 } elseif (isset($_SESSION['language_choice'])) {
396 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
397 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
398 if ($_SESSION['language_direction'] == 'rtl' &&
399 !strpos($GLOBALS['css_header'], 'rtl')) {
400 // the $css_header_value is set above
401 $rtl_override = true;
403 } else {
404 //$_SESSION['language_direction'] is not set, so will use the default language
405 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
407 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
408 // @todo eliminate 1 SQL query
409 $rtl_override = true;
414 // change theme name, if the override file exists.
415 if ($rtl_override) {
416 // the $css_header_value is set above
417 $new_theme = 'rtl_' . $temp_css_theme_name;
419 // Check file existance
420 if (file_exists($webserver_root.'/public/themes/'.$new_theme)) {
421 //Escape css file name using 'attr' for security (prevent XSS).
422 $GLOBALS['css_header'] = $web_root.'/public/themes/'.attr($new_theme).'?v='.$v_js_includes;
423 $css_header = $GLOBALS['css_header'];
424 } else {
425 // throw a warning if rtl'ed file does not exist.
426 error_log("Missing theme file " . errorLogEscape($webserver_root) . '/public/themes/' . errorLogEscape($new_theme));
430 unset($temp_css_theme_name, $new_theme, $rtl_override);
431 // end of RTL section
434 // End of globals table processing.
435 } else {
436 // Temporary stuff to handle the case where the globals table does not
437 // exist yet. This will happen in sql_upgrade.php on upgrading to the
438 // first release containing this table.
439 $GLOBALS['language_menu_login'] = true;
440 $GLOBALS['language_menu_showall'] = true;
441 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
442 $GLOBALS['language_default'] = "English (Standard)";
443 $GLOBALS['translate_layout'] = true;
444 $GLOBALS['translate_lists'] = true;
445 $GLOBALS['translate_gacl_groups'] = true;
446 $GLOBALS['translate_form_titles'] = true;
447 $GLOBALS['translate_document_categories'] = true;
448 $GLOBALS['translate_appt_categories'] = true;
449 $timeout = 7200;
450 $openemr_name = 'OpenEMR';
451 $css_header = "$web_root/public/themes/style_default.css";
452 $GLOBALS['css_header'] = $css_header;
453 $GLOBALS['schedule_start'] = 8;
454 $GLOBALS['schedule_end'] = 17;
455 $GLOBALS['calendar_interval'] = 15;
456 $GLOBALS['phone_country_code'] = '1';
457 $GLOBALS['disable_non_default_groups'] = true;
458 $GLOBALS['ippf_specific'] = false;
461 // If >0 this will enforce a separate PHP session for each top-level
462 // browser window. You must log in separately for each. This is not
463 // thoroughly tested yet and some browsers might have trouble with it,
464 // so make it 0 if you must. Alternatively, you can set it to 2 to be
465 // notified when the session ID changes.
466 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
468 // Theme definition. All this stuff should be moved to CSS.
470 $top_bg_line = ' bgcolor="#dddddd" ';
471 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
472 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
473 // optimal size for the tiny logo is height 43 width 86 px
474 // inside the open emr they will be auto reduced
475 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
476 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
478 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
479 // The height in pixels of the Title bar:
480 $GLOBALS['titleBarHeight'] = 50;
482 // The assistant word, MORE printed next to titles that can be clicked:
483 // Note this label gets translated here via the xl function
484 // -if you don't want it translated, then strip the xl function away
485 $tmore = xl('(More)');
486 // The assistant word, BACK printed next to titles that return to previous screens:
487 // Note this label gets translated here via the xl function
488 // -if you don't want it translated, then strip the xl function away
489 $tback = xl('(Back)');
491 // This is the idle logout function:
492 // if a page has not been refreshed within this many seconds, the interface
493 // will return to the login page
494 if (!empty($special_timeout)) {
495 $timeout = intval($special_timeout);
498 $versionService = new \OpenEMR\Services\VersionService();
499 $version = $versionService->fetch();
501 if (!empty($version)) {
502 //Version tag
503 $patch_appending = "";
504 //Collected below function call to a variable, since unable to directly include
505 // function calls within empty() in php versions < 5.5 .
506 $version_getrealpatch = $version->getRealPatch();
507 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
508 $patch_appending = " (".$version->getRealPatch().")";
511 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
512 $openemr_version .= $version->getTag() . $patch_appending;
513 } else {
514 $openemr_version = xl('Unknown version');
517 $srcdir = $GLOBALS['srcdir'];
518 $login_screen = $GLOBALS['login_screen'];
519 $GLOBALS['backpic'] = $backpic;
521 // 1 = send email message to given id for Emergency Login user activation,
522 // else 0.
523 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
525 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
526 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
527 //functions, tables for de-identification(Mysql root user and password is required for successful
528 //execution of the de-identification upgrade script)
529 $GLOBALS['include_de_identification']=0;
530 // Include the authentication module code here, but the rule is
531 // if the file has the word "login" in the source code file name,
532 // don't include the authentication module - we do this to avoid
533 // include loops.
535 if (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
536 $ignoreAuth = true;
539 if (!$ignoreAuth) {
540 require_once("$srcdir/auth.inc");
544 // This is the background color to apply to form fields that are searchable.
545 // Currently it is applicable only to the "Search or Add Patient" form.
546 $GLOBALS['layout_search_color'] = '#ff9919';
548 //EMAIL SETTINGS
549 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
552 //module configurations
553 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
554 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
555 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
557 try {
558 // load up the modules system and bootstrap them.
559 // This has to be fast, so any modules that tie into the bootstrap must be kept lightweight
560 // registering event listeners, etc.
561 // 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?
562 /** @var ModulesApplication */
563 $GLOBALS['modules_application'] = new ModulesApplication(
564 $GLOBALS["kernel"],
565 $GLOBALS['fileroot'],
566 $GLOBALS['baseModDir'],
567 $GLOBALS['zendModDir']
569 } catch (\Exception $ex) {
570 error_log(errorLogEscape($ex->getMessage() . $ex->getTraceAsString()));
571 die();
574 // Don't change anything below this line. ////////////////////////////
576 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
578 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
579 $_SESSION['pid'] = $_GET['pid'];
580 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
581 $_SESSION['pid'] = $_POST['pid'];
584 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
585 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
586 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
588 //This is crucial for therapy groups and patients mechanisms to work together properly
589 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
590 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
592 // global interface function to format text length using ellipses
593 function strterm($string, $length)
595 if (strlen($string) >= ($length-3)) {
596 return substr($string, 0, $length-3) . "...";
597 } else {
598 return $string;
602 // Override temporary_files_dir
603 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
605 // turn off PHP compatibility warnings
606 ini_set("session.bug_compat_warn", "off");
607 // user debug mode
608 if ((int) $GLOBALS['user_debug'] > 1) {
609 error_reporting(error_reporting() & ~E_WARNING & ~E_NOTICE & ~E_USER_WARNING);
610 ini_set('display_errors', 1);