mighty bug fixes (#1979)
[openemr.git] / interface / globals.php
blobc27124933bf129707773eb2af1d42cc7098f3ec7
1 <?php
3 /**
4 * Default values for optional variables that are allowed to be set by callers.
6 * @package OpenEMR
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @link http://www.open-emr.org
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
10 * @copyright Copyright (c) 2018 Brady Miller
13 // Checks if the server's PHP version is compatible with OpenEMR:
14 require_once(dirname(__FILE__) . "/../common/compatibility/Checker.php");
16 use OpenEMR\Common\Checker;
17 use OpenEMR\Core\Kernel;
18 use Dotenv\Dotenv;
20 $response = Checker::checkPhpVersion();
21 if ($response !== true) {
22 die($response);
25 //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.
26 $GLOBALS['debug_ssl_mysql_connection'] = false;
28 // Unless specified explicitly, apply Auth functions
29 if (!isset($ignoreAuth)) {
30 $ignoreAuth = false;
33 // Unless specified explicitly, caller is not offsite_portal and Auth is required
34 if (!isset($ignoreAuth_offsite_portal)) {
35 $ignoreAuth_offsite_portal = false;
38 // Same for onsite
39 if (!isset($ignoreAuth_onsite_portal_two)) {
40 $ignoreAuth_onsite_portal_two = false;
43 // Is this windows or non-windows? Create a boolean definition.
44 if (!defined('IS_WINDOWS')) {
45 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
48 // Some important php.ini overrides. Defaults for these values are often
49 // too small. You might choose to adjust them further.
51 ini_set('session.gc_maxlifetime', '14400');
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 // The session name names a cookie stored in the browser.
93 // Now that restore_session() is implemented in javaScript, session IDs are
94 // effectively saved in the top level browser window and there is no longer
95 // any need to change the session name for different OpenEMR instances.
96 // On 4/8/17, added cookie_path to improve security when using different
97 // OpenEMR instances on same server to prevent session conflicts; also
98 // modified interface/login/login.php and library/restoreSession.php to be
99 // consistent with this.
100 ini_set('session.cookie_path', $web_root ? $web_root : '/');
101 session_name("OpenEMR");
103 session_start();
105 // Set the site ID if required. This must be done before any database
106 // access is attempted.
107 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
108 if (!empty($_GET['site'])) {
109 $tmp = $_GET['site'];
110 } else {
111 if (empty($ignoreAuth)) {
112 // mdsupport - Don't die if logout menu link is called from expired session.
113 // Eliminate this code when close method is available for session management.
114 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
115 $GLOBALS['login_screen'] = "login_screen.php";
116 $srcdir = "../library";
117 include_once("$srcdir/auth.inc");
119 die("Site ID is missing from session data!");
122 $tmp = $_SERVER['HTTP_HOST'];
123 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
124 $tmp = "default";
128 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
129 die("Site ID '". htmlspecialchars($tmp, ENT_NOQUOTES) . "' contains invalid characters.");
132 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
133 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
134 session_unset(); // clear session, clean logout
135 if (isset($landingpage) && !empty($landingpage)) {
136 // OpenEMR Patient Portal use
137 header('Location: index.php?site='.$tmp);
138 } else {
139 // Main OpenEMR use
140 header('Location: ../login/login.php?site='.$tmp); // Assuming in the interface/main directory
143 exit;
146 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
147 $_SESSION['site_id'] = $tmp;
148 //error_log("Session site ID has been set to '$tmp'"); // debugging
152 // Set the site-specific directory path.
153 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
155 // Set a site-specific uri root path.
156 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
158 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
160 // Collecting the utf8 disable flag from the sqlconf.php file in order
161 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
162 // then set to iso-8859-1.
163 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
164 if (!$disable_utf8_flag) {
165 ini_set('default_charset', 'utf-8');
166 $HTML_CHARSET = "UTF-8";
167 mb_internal_encoding('UTF-8');
168 } else {
169 ini_set('default_charset', 'iso-8859-1');
170 $HTML_CHARSET = "ISO-8859-1";
171 mb_internal_encoding('ISO-8859-1');
174 // Root directory, relative to the webserver root:
175 $GLOBALS['rootdir'] = "$web_root/interface";
176 $rootdir = $GLOBALS['rootdir'];
177 // Absolute path to the source code include and headers file directory (Full path):
178 $GLOBALS['srcdir'] = "$webserver_root/library";
179 // Absolute path to the location of documentroot directory for use with include statements:
180 $GLOBALS['fileroot'] = "$webserver_root";
181 // Absolute path to the location of interface directory for use with include statements:
182 $include_root = "$webserver_root/interface";
183 // Absolute path to the location of documentroot directory for use with include statements:
184 $GLOBALS['webroot'] = $web_root;
186 // Static assets directory, relative to the webserver root.
187 // (it is very likely that this path will be changed in the future))
188 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
190 // Relative images directory, relative to the webserver root.
191 $GLOBALS['images_static_relative'] = "$web_root/public/images";
193 // Static images directory, absolute to the webserver root.
194 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
196 //Composer vendor directory, absolute to the webserver root.
197 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
198 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
199 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
200 $GLOBALS['incdir'] = $include_root;
201 // Location of the login screen file
202 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
204 // Variable set for Eligibility Verification [EDI-271] path
205 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
207 // Set and check that necessary writeable path exist for mPDF tool
208 $GLOBALS['MPDF_WRITE_DIR'] = $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp';
209 if (! is_dir($GLOBALS['MPDF_WRITE_DIR'])) {
210 mkdir($GLOBALS['MPDF_WRITE_DIR'], 0755, true);
213 // Includes composer autoload
214 // Note this also brings in following library files:
215 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
216 // library/formdata.inc.php - Include sanitization/checking functions (for security)
217 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
218 // library/date_functions.php - Includes functions for date internationalization
219 // library/validation/validate_core.php - Includes functions for page validation
220 // library/translation.inc.php - Includes translation functions
221 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
223 // Set up csrf token
224 // This is done in cases where it is not yet set for the session
225 // (note this is permanently done for the session in the main_screen.php script)
226 if (empty($_SESSION['csrf_token'])) {
227 $_SESSION['csrf_token'] = createCsrfToken();
231 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
233 * This allows to define a "development" environment which can then load up
234 * different variables and reporting/debugging functionality. Should be used in
235 * development only, not for production
237 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
239 if (file_exists("{$webserver_root}/.env")) {
240 $dotenv = new Dotenv($webserver_root);
241 $dotenv->load();
244 // @TODO This needs to be broken out to it's own function, but for time's sake
245 // @TODO putting it here until we land on a good place. RD 2017-05-02
247 $twigOptions = [
248 'debug' => false,
251 $twigLoader = new Twig_Loader_Filesystem();
252 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
254 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
255 $twigEnv->addExtension(new Twig_Extension_Debug());
258 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
259 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
260 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
261 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
262 return xl($string);
263 }));
265 /** Twig_Loader */
266 $GLOBALS['twigLoader'] = $twigLoader;
267 /** Twig_Environment */
268 $GLOBALS['twig'] = $twigEnv;
270 // This will open the openemr mysql connection.
271 require_once(dirname(__FILE__) . "/../library/sql.inc");
273 // Include the version file
274 require_once(dirname(__FILE__) . "/../version.php");
276 // The logging level for common/logging/logger.php
277 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
278 // - DEBUG/INFO are great for development
279 // - INFO/WARN/ERROR are great for production
280 // - TRACE is useful when debugging hard to spot bugs
281 $GLOBALS["log_level"] = "OFF";
283 try {
284 /** @var Kernel */
285 $GLOBALS["kernel"] = new Kernel();
286 } catch (\Exception $e) {
287 error_log($e->getMessage());
288 die();
291 // Should Doctrine make use of connection pooling? Database connection pooling is a method
292 // used to keep database connections open so they can be reused by others. (The only reason
293 // to not use connection pooling is if your server has limited resources.)
294 $GLOBALS["doctrine_connection_pooling"] = true;
296 // Defaults for specific applications.
297 $GLOBALS['weight_loss_clinic'] = false;
298 $GLOBALS['ippf_specific'] = false;
300 // Defaults for drugs and products.
301 $GLOBALS['inhouse_pharmacy'] = false;
302 $GLOBALS['sell_non_drug_products'] = 0;
304 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
305 if (!empty($glrow)) {
306 // Collect user specific settings from user_settings table.
308 $gl_user = array();
309 // Collect the user id first
310 $temp_authuserid = '';
311 if (!empty($_SESSION['authUserID'])) {
312 //Set the user id from the session variable
313 $temp_authuserid = $_SESSION['authUserID'];
314 } else {
315 if (!empty($_POST['authUser'])) {
316 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
317 if (!empty($temp_sql_ret['id'])) {
318 //Set the user id from the login variable
319 $temp_authuserid = $temp_sql_ret['id'];
324 if (!empty($temp_authuserid)) {
325 $glres_user = sqlStatement(
326 "SELECT `setting_label`, `setting_value` " .
327 "FROM `user_settings` " .
328 "WHERE `setting_user` = ? " .
329 "AND `setting_label` LIKE 'global:%'",
330 array($temp_authuserid)
332 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
333 //remove global_ prefix from label
334 $row['setting_label'] = substr($row['setting_label'], 7);
335 $gl_user[$iter]=$row;
339 // Set global parameters from the database globals table.
340 // Some parameters require custom handling.
342 $GLOBALS['language_menu_show'] = array();
343 $glres = sqlStatement(
344 "SELECT gl_name, gl_index, gl_value FROM globals " .
345 "ORDER BY gl_name, gl_index"
347 while ($glrow = sqlFetchArray($glres)) {
348 $gl_name = $glrow['gl_name'];
349 $gl_value = $glrow['gl_value'];
350 // Adjust for user specific settings
351 if (!empty($gl_user)) {
352 foreach ($gl_user as $setting) {
353 if ($gl_name == $setting['setting_label']) {
354 $gl_value = $setting['setting_value'];
359 if ($gl_name == 'language_menu_other') {
360 $GLOBALS['language_menu_show'][] = $gl_value;
361 } elseif ($gl_name == 'css_header') {
362 //Escape css file name using 'attr' for security (prevent XSS).
363 $GLOBALS[$gl_name] = $web_root.'/public/themes/'.attr($gl_value).'?v='.$v_js_includes;
364 $css_header = $GLOBALS[$gl_name];
365 $temp_css_theme_name = $gl_value;
366 } elseif ($gl_name == 'weekend_days') {
367 $GLOBALS[$gl_name] = explode(',', $gl_value);
368 } elseif ($gl_name == 'specific_application') {
369 if ($gl_value == '2') {
370 $GLOBALS['ippf_specific'] = true;
371 } elseif ($gl_value == '3') {
372 $GLOBALS['weight_loss_clinic'] = true;
374 } elseif ($gl_name == 'inhouse_pharmacy') {
375 if ($gl_value) {
376 $GLOBALS['inhouse_pharmacy'] = true;
379 if ($gl_value == '2') {
380 $GLOBALS['sell_non_drug_products'] = 1;
381 } elseif ($gl_value == '3') {
382 $GLOBALS['sell_non_drug_products'] = 2;
384 } elseif ($gl_name == 'gbl_time_zone') {
385 // The default PHP time zone is set here if it was specified, and is used
386 // as source data for the MySQL time zone here and in some other places
387 // where MySQL connections are opened.
388 if ($gl_value) {
389 date_default_timezone_set($gl_value);
392 // Synchronize MySQL time zone with PHP time zone.
393 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
394 } else {
395 $GLOBALS[$gl_name] = $gl_value;
399 // Language cleanup stuff.
400 $GLOBALS['language_menu_login'] = false;
401 if ((count($GLOBALS['language_menu_show']) > 1) || $GLOBALS['language_menu_showall']) {
402 $GLOBALS['language_menu_login'] = true;
405 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
406 // that may use this; note this global has been removed from the standard codebase.
407 $GLOBALS['concurrent_layout'] = 3;
409 // Additional logic to override theme name.
410 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
411 $rtl_override = false;
412 if (isset($_SESSION['language_direction'])) {
413 if ($_SESSION['language_direction'] == 'rtl' &&
414 !strpos($GLOBALS['css_header'], 'rtl') ) {
415 // the $css_header_value is set above
416 $rtl_override = true;
418 } elseif (isset($_SESSION['language_choice'])) {
419 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
420 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
421 if ($_SESSION['language_direction'] == 'rtl' &&
422 !strpos($GLOBALS['css_header'], 'rtl')) {
423 // the $css_header_value is set above
424 $rtl_override = true;
426 } else {
427 //$_SESSION['language_direction'] is not set, so will use the default language
428 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
430 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
431 // @todo eliminate 1 SQL query
432 $rtl_override = true;
437 // change theme name, if the override file exists.
438 if ($rtl_override) {
439 // the $css_header_value is set above
440 $new_theme = 'rtl_' . $temp_css_theme_name;
442 // Check file existance
443 if (file_exists($webserver_root.'/public/themes/'.$new_theme)) {
444 //Escape css file name using 'attr' for security (prevent XSS).
445 $GLOBALS['css_header'] = $web_root.'/public/themes/'.attr($new_theme).'?v='.$v_js_includes;
446 $css_header = $GLOBALS['css_header'];
447 } else {
448 // throw a warning if rtl'ed file does not exist.
449 error_log("Missing theme file ".text($webserver_root).'/public/themes/'.text($new_theme));
453 unset($temp_css_theme_name, $new_theme, $rtl_override);
454 // end of RTL section
457 // End of globals table processing.
458 } else {
459 // Temporary stuff to handle the case where the globals table does not
460 // exist yet. This will happen in sql_upgrade.php on upgrading to the
461 // first release containing this table.
462 $GLOBALS['language_menu_login'] = true;
463 $GLOBALS['language_menu_showall'] = true;
464 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
465 $GLOBALS['language_default'] = "English (Standard)";
466 $GLOBALS['translate_layout'] = true;
467 $GLOBALS['translate_lists'] = true;
468 $GLOBALS['translate_gacl_groups'] = true;
469 $GLOBALS['translate_form_titles'] = true;
470 $GLOBALS['translate_document_categories'] = true;
471 $GLOBALS['translate_appt_categories'] = true;
472 $timeout = 7200;
473 $openemr_name = 'OpenEMR';
474 $css_header = "$web_root/public/themes/style_default.css";
475 $GLOBALS['css_header'] = $css_header;
476 $GLOBALS['schedule_start'] = 8;
477 $GLOBALS['schedule_end'] = 17;
478 $GLOBALS['calendar_interval'] = 15;
479 $GLOBALS['phone_country_code'] = '1';
480 $GLOBALS['disable_non_default_groups'] = true;
481 $GLOBALS['ippf_specific'] = false;
484 // If >0 this will enforce a separate PHP session for each top-level
485 // browser window. You must log in separately for each. This is not
486 // thoroughly tested yet and some browsers might have trouble with it,
487 // so make it 0 if you must. Alternatively, you can set it to 2 to be
488 // notified when the session ID changes.
489 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
491 // Theme definition. All this stuff should be moved to CSS.
493 $top_bg_line = ' bgcolor="#dddddd" ';
494 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
495 $bottom_bg_line = $top_bg_line;
496 $title_bg_line = ' bgcolor="#bbbbbb" ';
497 $nav_bg_line = ' bgcolor="#94d6e7" ';
498 $login_filler_line = ' bgcolor="#f7f0d5" ';
499 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
500 // optimal size for the tiny logo is height 43 width 86 px
501 // inside the open emr they will be auto reduced
502 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
503 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
505 $table_bg = ' bgcolor="#cccccc" ';
506 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
507 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
508 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
509 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
510 // The height in pixels of the Logo bar at the top of the login page:
511 $GLOBALS['logoBarHeight'] = 110;
512 // The height in pixels of the Navigation bar:
513 $GLOBALS['navBarHeight'] = 22;
514 // The height in pixels of the Title bar:
515 $GLOBALS['titleBarHeight'] = 50;
517 // The assistant word, MORE printed next to titles that can be clicked:
518 // Note this label gets translated here via the xl function
519 // -if you don't want it translated, then strip the xl function away
520 $tmore = xl('(More)');
521 // The assistant word, BACK printed next to titles that return to previous screens:
522 // Note this label gets translated here via the xl function
523 // -if you don't want it translated, then strip the xl function away
524 $tback = xl('(Back)');
526 // This is the idle logout function:
527 // if a page has not been refreshed within this many seconds, the interface
528 // will return to the login page
529 if (!empty($special_timeout)) {
530 $timeout = intval($special_timeout);
533 $versionService = new \OpenEMR\Services\VersionService();
534 $version = $versionService->fetch();
536 if (!empty($version)) {
537 //Version tag
538 $patch_appending = "";
539 //Collected below function call to a variable, since unable to directly include
540 // function calls within empty() in php versions < 5.5 .
541 $version_getrealpatch = $version->getRealPatch();
542 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
543 $patch_appending = " (".$version->getRealPatch().")";
546 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
547 $openemr_version .= $version->getTag() . $patch_appending;
548 } else {
549 $openemr_version = xl('Unknown version');
552 $srcdir = $GLOBALS['srcdir'];
553 $login_screen = $GLOBALS['login_screen'];
554 $GLOBALS['backpic'] = $backpic;
556 // 1 = send email message to given id for Emergency Login user activation,
557 // else 0.
558 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
560 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
561 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
562 //functions, tables for de-identification(Mysql root user and password is required for successful
563 //execution of the de-identification upgrade script)
564 $GLOBALS['include_de_identification']=0;
565 // Include the authentication module code here, but the rule is
566 // if the file has the word "login" in the source code file name,
567 // don't include the authentication module - we do this to avoid
568 // include loops.
570 if (($ignoreAuth_offsite_portal === true) && ($GLOBALS['portal_offsite_enable'] == 1)) {
571 $ignoreAuth = true;
572 } elseif (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
573 $ignoreAuth = true;
576 if (!$ignoreAuth) {
577 include_once("$srcdir/auth.inc");
581 // This is the background color to apply to form fields that are searchable.
582 // Currently it is applicable only to the "Search or Add Patient" form.
583 $GLOBALS['layout_search_color'] = '#ff9919';
585 //EMAIL SETTINGS
586 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
589 //module configurations
590 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
591 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
592 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
594 // Don't change anything below this line. ////////////////////////////
596 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
598 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
599 $_SESSION['pid'] = $_GET['pid'];
600 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
601 $_SESSION['pid'] = $_POST['pid'];
604 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
605 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
606 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
608 //This is crucial for therapy groups and patients mechanisms to work together properly
609 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
610 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
612 // global interface function to format text length using ellipses
613 function strterm($string, $length)
615 if (strlen($string) >= ($length-3)) {
616 return substr($string, 0, $length-3) . "...";
617 } else {
618 return $string;
622 // Override temporary_files_dir if PHP >= 5.2.1.
623 if (version_compare(phpversion(), "5.2.1", ">=")) {
624 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
627 // turn off PHP compatibility warnings
628 ini_set("session.bug_compat_warn", "off");