Highway to PSR2
[openemr.git] / interface / globals.php
blobc62297f70cbeb3382f2c2cfd1e3ae0a4f28e2e24
1 <?php
3 // Checks if the server's PHP version is compatible with OpenEMR:
4 require_once(dirname(__FILE__) . "/../common/compatibility/Checker.php");
6 use OpenEMR\Checker;
7 use OpenEMR\Core\Kernel;
8 use Dotenv\Dotenv;
10 $response = Checker::checkPhpVersion();
11 if ($response !== true) {
12 die($response);
15 // Default values for optional variables that are allowed to be set by callers.
17 // Unless specified explicitly, apply Auth functions
18 if (!isset($ignoreAuth)) {
19 $ignoreAuth = false;
22 // Unless specified explicitly, caller is not offsite_portal and Auth is required
23 if (!isset($ignoreAuth_offsite_portal)) {
24 $ignoreAuth_offsite_portal = false;
27 // Same for onsite
28 if (!isset($ignoreAuth_onsite_portal_two)) {
29 $ignoreAuth_onsite_portal_two = false;
32 // Is this windows or non-windows? Create a boolean definition.
33 if (!defined('IS_WINDOWS')) {
34 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
37 // Some important php.ini overrides. Defaults for these values are often
38 // too small. You might choose to adjust them further.
40 ini_set('session.gc_maxlifetime', '14400');
42 // The webserver_root and web_root are now automatically collected.
43 // If not working, can set manually below.
44 // Auto collect the full absolute directory path for openemr.
45 $webserver_root = dirname(dirname(__FILE__));
46 if (IS_WINDOWS) {
47 //convert windows path separators
48 $webserver_root = str_replace("\\", "/", $webserver_root);
51 // Collect the apache server document root (and convert to windows slashes, if needed)
52 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
53 if (IS_WINDOWS) {
54 //convert windows path separators
55 $server_document_root = str_replace("\\", "/", $server_document_root);
58 // Auto collect the relative html path, i.e. what you would type into the web
59 // browser after the server address to get to OpenEMR.
60 // This removes the leading portion of $webserver_root that it has in common with the web server's document
61 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
62 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
63 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
64 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
65 // Ensure web_root starts with a path separator
66 if (preg_match("/^[^\/]/", $web_root)) {
67 $web_root = "/".$web_root;
70 // The webserver_root and web_root are now automatically collected in
71 // real time per above code. If above is not working, can uncomment and
72 // set manually here:
73 // $webserver_root = "/var/www/openemr";
74 // $web_root = "/openemr";
77 // This is the directory that contains site-specific data. Change this
78 // only if you have some reason to.
79 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
81 // The session name names a cookie stored in the browser.
82 // Now that restore_session() is implemented in javaScript, session IDs are
83 // effectively saved in the top level browser window and there is no longer
84 // any need to change the session name for different OpenEMR instances.
85 // On 4/8/17, added cookie_path to improve security when using different
86 // OpenEMR instances on same server to prevent session conflicts; also
87 // modified interface/login/login.php and library/restoreSession.php to be
88 // consistent with this.
89 ini_set('session.cookie_path', $web_root ? $web_root : '/');
90 session_name("OpenEMR");
92 session_start();
94 // Set the site ID if required. This must be done before any database
95 // access is attempted.
96 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
97 if (!empty($_GET['site'])) {
98 $tmp = $_GET['site'];
99 } else {
100 if (empty($ignoreAuth)) {
101 die("Site ID is missing from session data!");
104 $tmp = $_SERVER['HTTP_HOST'];
105 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
106 $tmp = "default";
110 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
111 die("Site ID '". htmlspecialchars($tmp, ENT_NOQUOTES) . "' contains invalid characters.");
114 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
115 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
116 session_unset(); // clear session, clean logout
117 if (isset($landingpage) && !empty($landingpage)) {
118 // OpenEMR Patient Portal use
119 header('Location: index.php?site='.$tmp);
120 } else {
121 // Main OpenEMR use
122 header('Location: ../login/login.php?site='.$tmp); // Assuming in the interface/main directory
125 exit;
128 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
129 $_SESSION['site_id'] = $tmp;
130 //error_log("Session site ID has been set to '$tmp'"); // debugging
134 // Set the site-specific directory path.
135 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
137 // Set a site-specific uri root path.
138 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
140 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
142 // Collecting the utf8 disable flag from the sqlconf.php file in order
143 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
144 // then set to iso-8859-1.
145 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
146 if (!$disable_utf8_flag) {
147 ini_set('default_charset', 'utf-8');
148 $HTML_CHARSET = "UTF-8";
149 mb_internal_encoding('UTF-8');
150 } else {
151 ini_set('default_charset', 'iso-8859-1');
152 $HTML_CHARSET = "ISO-8859-1";
153 mb_internal_encoding('ISO-8859-1');
156 // Root directory, relative to the webserver root:
157 $GLOBALS['rootdir'] = "$web_root/interface";
158 $rootdir = $GLOBALS['rootdir'];
159 // Absolute path to the source code include and headers file directory (Full path):
160 $GLOBALS['srcdir'] = "$webserver_root/library";
161 // Absolute path to the location of documentroot directory for use with include statements:
162 $GLOBALS['fileroot'] = "$webserver_root";
163 // Absolute path to the location of interface directory for use with include statements:
164 $include_root = "$webserver_root/interface";
165 // Absolute path to the location of documentroot directory for use with include statements:
166 $GLOBALS['webroot'] = $web_root;
168 // Static assets directory, relative to the webserver root.
169 // (it is very likely that this path will be changed in the future))
170 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
172 // Relative images directory, relative to the webserver root.
173 $GLOBALS['images_static_relative'] = "$web_root/public/images";
175 // Static images directory, absolute to the webserver root.
176 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
178 //Composer vendor directory, absolute to the webserver root.
179 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
180 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
181 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
182 $GLOBALS['incdir'] = $include_root;
183 // Location of the login screen file
184 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
186 // Variable set for Eligibility Verification [EDI-271] path
187 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
189 // Check necessary writeable paths exist for mPDF tool
190 if (is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/')) {
191 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/')) {
192 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755);
195 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/')) {
196 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
198 } else {
199 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755, true);
200 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
203 // Safe bet support directories exist, define them.
204 define("_MPDF_TEMP_PATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/');
205 define("_MPDF_TTFONTDATAPATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/');
207 // Includes composer autoload
208 // Note this also brings in following library files:
209 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
210 // library/formdata.inc.php - Include sanitization/checking functions (for security)
211 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
212 // library/date_functions.php - Includes functions for date internationalization
213 // library/validation/validate_core.php - Includes functions for page validation
214 // library/translation.inc.php - Includes translation functions
215 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
218 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
220 * This allows to define a "development" environment which can then load up
221 * different variables and reporting/debugging functionality. Should be used in
222 * development only, not for production
224 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
226 if (file_exists("{$webserver_root}/.env")) {
227 $dotenv = new Dotenv($webserver_root);
228 $dotenv->load();
231 // @TODO This needs to be broken out to it's own function, but for time's sake
232 // @TODO putting it here until we land on a good place. RD 2017-05-02
234 $twigOptions = [
235 'debug' => false,
238 $twigLoader = new Twig_Loader_Filesystem();
239 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
241 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
242 $twigEnv->addExtension(new Twig_Extension_Debug());
245 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
246 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
247 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
248 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
249 return xl($string);
250 }));
252 /** Twig_Loader */
253 $GLOBALS['twigLoader'] = $twigLoader;
254 /** Twig_Environment */
255 $GLOBALS['twig'] = $twigEnv;
257 // This will open the openemr mysql connection.
258 require_once(dirname(__FILE__) . "/../library/sql.inc");
260 // Include the version file
261 require_once(dirname(__FILE__) . "/../version.php");
263 // The logging level for common/logging/logger.php
264 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
265 // - DEBUG/INFO are great for development
266 // - INFO/WARN/ERROR are great for production
267 // - TRACE is useful when debugging hard to spot bugs
268 $GLOBALS["log_level"] = "OFF";
270 try {
271 /** @var Kernel */
272 $GLOBALS["kernel"] = new Kernel();
273 } catch (\Exception $e) {
274 error_log($e->getMessage());
275 die();
278 // Should Doctrine make use of connection pooling? Database connection pooling is a method
279 // used to keep database connections open so they can be reused by others. (The only reason
280 // to not use connection pooling is if your server has limited resources.)
281 $GLOBALS["doctrine_connection_pooling"] = true;
283 // Defaults for specific applications.
284 $GLOBALS['weight_loss_clinic'] = false;
285 $GLOBALS['ippf_specific'] = false;
287 // Defaults for drugs and products.
288 $GLOBALS['inhouse_pharmacy'] = false;
289 $GLOBALS['sell_non_drug_products'] = 0;
291 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
292 if (!empty($glrow)) {
293 // Collect user specific settings from user_settings table.
295 $gl_user = array();
296 // Collect the user id first
297 $temp_authuserid = '';
298 if (!empty($_SESSION['authUserID'])) {
299 //Set the user id from the session variable
300 $temp_authuserid = $_SESSION['authUserID'];
301 } else {
302 if (!empty($_POST['authUser'])) {
303 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
304 if (!empty($temp_sql_ret['id'])) {
305 //Set the user id from the login variable
306 $temp_authuserid = $temp_sql_ret['id'];
311 if (!empty($temp_authuserid)) {
312 $glres_user = sqlStatement(
313 "SELECT `setting_label`, `setting_value` " .
314 "FROM `user_settings` " .
315 "WHERE `setting_user` = ? " .
316 "AND `setting_label` LIKE 'global:%'",
317 array($temp_authuserid)
319 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
320 //remove global_ prefix from label
321 $row['setting_label'] = substr($row['setting_label'], 7);
322 $gl_user[$iter]=$row;
326 // Set global parameters from the database globals table.
327 // Some parameters require custom handling.
329 $GLOBALS['language_menu_show'] = array();
330 $glres = sqlStatement(
331 "SELECT gl_name, gl_index, gl_value FROM globals " .
332 "ORDER BY gl_name, gl_index"
334 while ($glrow = sqlFetchArray($glres)) {
335 $gl_name = $glrow['gl_name'];
336 $gl_value = $glrow['gl_value'];
337 // Adjust for user specific settings
338 if (!empty($gl_user)) {
339 foreach ($gl_user as $setting) {
340 if ($gl_name == $setting['setting_label']) {
341 $gl_value = $setting['setting_value'];
346 if ($gl_name == 'language_menu_other') {
347 $GLOBALS['language_menu_show'][] = $gl_value;
348 } elseif ($gl_name == 'css_header') {
349 $GLOBALS[$gl_name] = $rootdir.'/themes/'.$gl_value.'?v='.$v_js_includes;
350 $temp_css_theme_name = $gl_value;
351 } elseif ($gl_name == 'weekend_days') {
352 $GLOBALS[$gl_name] = explode(',', $gl_value);
353 } elseif ($gl_name == 'specific_application') {
354 if ($gl_value == '2') {
355 $GLOBALS['ippf_specific'] = true;
356 } elseif ($gl_value == '3') {
357 $GLOBALS['weight_loss_clinic'] = true;
359 } elseif ($gl_name == 'inhouse_pharmacy') {
360 if ($gl_value) {
361 $GLOBALS['inhouse_pharmacy'] = true;
364 if ($gl_value == '2') {
365 $GLOBALS['sell_non_drug_products'] = 1;
366 } elseif ($gl_value == '3') {
367 $GLOBALS['sell_non_drug_products'] = 2;
369 } elseif ($gl_name == 'gbl_time_zone') {
370 // The default PHP time zone is set here if it was specified, and is used
371 // as source data for the MySQL time zone here and in some other places
372 // where MySQL connections are opened.
373 if ($gl_value) {
374 date_default_timezone_set($gl_value);
377 // Synchronize MySQL time zone with PHP time zone.
378 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
379 } else {
380 $GLOBALS[$gl_name] = $gl_value;
384 // Language cleanup stuff.
385 $GLOBALS['language_menu_login'] = false;
386 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
387 $GLOBALS['language_menu_login'] = true;
390 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
391 // that may use this; note this global has been removed from the standard codebase.
392 $GLOBALS['concurrent_layout'] = 3;
394 // Additional logic to override theme name.
395 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
396 $rtl_override = false;
397 if (isset($_SESSION['language_direction'])) {
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 } elseif (isset($_SESSION['language_choice'])) {
404 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
405 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
406 if ($_SESSION['language_direction'] == 'rtl' &&
407 !strpos($GLOBALS['css_header'], 'rtl')) {
408 // the $css_header_value is set above
409 $rtl_override = true;
411 } else {
412 //$_SESSION['language_direction'] is not set, so will use the default language
413 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
415 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
416 // @todo eliminate 1 SQL query
417 $rtl_override = true;
422 // change theme name, if the override file exists.
423 if ($rtl_override) {
424 // the $css_header_value is set above
425 $new_theme = 'rtl_' . $temp_css_theme_name;
427 // Check file existance
428 if (file_exists($include_root.'/themes/'.$new_theme)) {
429 $GLOBALS['css_header'] = $rootdir.'/themes/'.$new_theme.'?v='.$v_js_includes;
430 } else {
431 // throw a warning if rtl'ed file does not exist.
432 error_log("Missing theme file ".text($include_root).'/themes/'.text($new_theme));
436 unset($temp_css_theme_name, $new_theme, $rtl_override);
437 // end of RTL section
440 // End of globals table processing.
441 } else {
442 // Temporary stuff to handle the case where the globals table does not
443 // exist yet. This will happen in sql_upgrade.php on upgrading to the
444 // first release containing this table.
445 $GLOBALS['language_menu_login'] = true;
446 $GLOBALS['language_menu_showall'] = true;
447 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
448 $GLOBALS['language_default'] = "English (Standard)";
449 $GLOBALS['translate_layout'] = true;
450 $GLOBALS['translate_lists'] = true;
451 $GLOBALS['translate_gacl_groups'] = true;
452 $GLOBALS['translate_form_titles'] = true;
453 $GLOBALS['translate_document_categories'] = true;
454 $GLOBALS['translate_appt_categories'] = true;
455 $timeout = 7200;
456 $openemr_name = 'OpenEMR';
457 $css_header = "$rootdir/themes/style_default.css";
458 $GLOBALS['css_header'] = $css_header;
459 $GLOBALS['schedule_start'] = 8;
460 $GLOBALS['schedule_end'] = 17;
461 $GLOBALS['calendar_interval'] = 15;
462 $GLOBALS['phone_country_code'] = '1';
463 $GLOBALS['disable_non_default_groups'] = true;
464 $GLOBALS['ippf_specific'] = false;
467 // If >0 this will enforce a separate PHP session for each top-level
468 // browser window. You must log in separately for each. This is not
469 // thoroughly tested yet and some browsers might have trouble with it,
470 // so make it 0 if you must. Alternatively, you can set it to 2 to be
471 // notified when the session ID changes.
472 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
474 // Theme definition. All this stuff should be moved to CSS.
476 $top_bg_line = ' bgcolor="#dddddd" ';
477 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
478 $bottom_bg_line = $top_bg_line;
479 $title_bg_line = ' bgcolor="#bbbbbb" ';
480 $nav_bg_line = ' bgcolor="#94d6e7" ';
481 $login_filler_line = ' bgcolor="#f7f0d5" ';
482 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
483 // optimal size for the tiny logo is height 43 width 86 px
484 // inside the open emr they will be auto reduced
485 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
486 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
488 $linepic = "$rootdir/pic/repeat_vline9.gif";
489 $table_bg = ' bgcolor="#cccccc" ';
490 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
491 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
492 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
493 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
494 // The height in pixels of the Logo bar at the top of the login page:
495 $GLOBALS['logoBarHeight'] = 110;
496 // The height in pixels of the Navigation bar:
497 $GLOBALS['navBarHeight'] = 22;
498 // The height in pixels of the Title bar:
499 $GLOBALS['titleBarHeight'] = 40;
501 // The assistant word, MORE printed next to titles that can be clicked:
502 // Note this label gets translated here via the xl function
503 // -if you don't want it translated, then strip the xl function away
504 $tmore = xl('(More)');
505 // The assistant word, BACK printed next to titles that return to previous screens:
506 // Note this label gets translated here via the xl function
507 // -if you don't want it translated, then strip the xl function away
508 $tback = xl('(Back)');
510 // This is the idle logout function:
511 // if a page has not been refreshed within this many seconds, the interface
512 // will return to the login page
513 if (!empty($special_timeout)) {
514 $timeout = intval($special_timeout);
517 $versionService = new \services\VersionService();
518 $version = $versionService->fetch();
520 if (!empty($version)) {
521 //Version tag
522 $patch_appending = "";
523 //Collected below function call to a variable, since unable to directly include
524 // function calls within empty() in php versions < 5.5 .
525 $version_getrealpatch = $version->getRealPatch();
526 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
527 $patch_appending = " (".$version->getRealPatch().")";
530 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
531 $openemr_version .= $version->getTag() . $patch_appending;
532 } else {
533 $openemr_version = xl('Unknown version');
536 $srcdir = $GLOBALS['srcdir'];
537 $login_screen = $GLOBALS['login_screen'];
538 $GLOBALS['css_header'] = $css_header;
539 $GLOBALS['backpic'] = $backpic;
541 // 1 = send email message to given id for Emergency Login user activation,
542 // else 0.
543 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
545 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
546 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
547 //functions, tables for de-identification(Mysql root user and password is required for successful
548 //execution of the de-identification upgrade script)
549 $GLOBALS['include_de_identification']=0;
550 // Include the authentication module code here, but the rule is
551 // if the file has the word "login" in the source code file name,
552 // don't include the authentication module - we do this to avoid
553 // include loops.
555 if (($ignoreAuth_offsite_portal === true) && ($GLOBALS['portal_offsite_enable'] == 1)) {
556 $ignoreAuth = true;
557 } elseif (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
558 $ignoreAuth = true;
561 if (!$ignoreAuth) {
562 include_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'] = '#ffff55';
570 //EMAIL SETTINGS
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
579 // Don't change anything below this line. ////////////////////////////
581 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
583 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
584 $_SESSION['pid'] = $_GET['pid'];
585 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
586 $_SESSION['pid'] = $_POST['pid'];
589 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
590 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
591 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
593 //This is crucial for therapy groups and patients mechanisms to work together properly
594 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
595 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
597 // global interface function to format text length using ellipses
598 function strterm($string, $length)
600 if (strlen($string) >= ($length-3)) {
601 return substr($string, 0, $length-3) . "...";
602 } else {
603 return $string;
607 // Override temporary_files_dir if PHP >= 5.2.1.
608 if (version_compare(phpversion(), "5.2.1", ">=")) {
609 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
612 // turn off PHP compatibility warnings
613 ini_set("session.bug_compat_warn", "off");