fixed newer version openssl issue where only lower case cipher is returned (#2109)
[openemr.git] / interface / globals.php
blobb71af88bf8e1bcfb12fe8d319b410254b5439260
1 <?php
2 /**
3 * Default values for optional variables that are allowed to be set by callers.
5 * @package OpenEMR
6 * @link http://www.open-emr.org
7 * @author Brady Miller <brady.g.miller@gmail.com>
8 * @copyright Copyright (c) 2018 Brady Miller <brady.g.miller@gmail.com>
9 * @license https://github.com/openemr/openemr/blob/master/LICENSE GNU General Public License 3
12 // Checks if the server's PHP version is compatible with OpenEMR:
13 require_once(dirname(__FILE__) . "/../common/compatibility/Checker.php");
15 use OpenEMR\Common\Checker;
16 use OpenEMR\Core\Kernel;
17 use Dotenv\Dotenv;
19 $response = Checker::checkPhpVersion();
20 if ($response !== true) {
21 die($response);
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)) {
41 $ignoreAuth = false;
44 // Unless specified explicitly, caller is not offsite_portal and Auth is required
45 if (!isset($ignoreAuth_offsite_portal)) {
46 $ignoreAuth_offsite_portal = false;
49 // Same for onsite
50 if (!isset($ignoreAuth_onsite_portal_two)) {
51 $ignoreAuth_onsite_portal_two = false;
54 // Is this windows or non-windows? Create a boolean definition.
55 if (!defined('IS_WINDOWS')) {
56 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
59 // Some important php.ini overrides. Defaults for these values are often
60 // too small. You might choose to adjust them further.
62 ini_set('session.gc_maxlifetime', '14400');
64 // The webserver_root and web_root are now automatically collected.
65 // If not working, can set manually below.
66 // Auto collect the full absolute directory path for openemr.
67 $webserver_root = dirname(dirname(__FILE__));
68 if (IS_WINDOWS) {
69 //convert windows path separators
70 $webserver_root = str_replace("\\", "/", $webserver_root);
73 // Collect the apache server document root (and convert to windows slashes, if needed)
74 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
75 if (IS_WINDOWS) {
76 //convert windows path separators
77 $server_document_root = str_replace("\\", "/", $server_document_root);
80 // Auto collect the relative html path, i.e. what you would type into the web
81 // browser after the server address to get to OpenEMR.
82 // This removes the leading portion of $webserver_root that it has in common with the web server's document
83 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
84 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
85 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
86 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
87 // Ensure web_root starts with a path separator
88 if (preg_match("/^[^\/]/", $web_root)) {
89 $web_root = "/".$web_root;
92 // The webserver_root and web_root are now automatically collected in
93 // real time per above code. If above is not working, can uncomment and
94 // set manually here:
95 // $webserver_root = "/var/www/openemr";
96 // $web_root = "/openemr";
99 // This is the directory that contains site-specific data. Change this
100 // only if you have some reason to.
101 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
103 // The session name names a cookie stored in the browser.
104 // Now that restore_session() is implemented in javaScript, session IDs are
105 // effectively saved in the top level browser window and there is no longer
106 // any need to change the session name for different OpenEMR instances.
107 // On 4/8/17, added cookie_path to improve security when using different
108 // OpenEMR instances on same server to prevent session conflicts; also
109 // modified interface/login/login.php and library/restoreSession.php to be
110 // consistent with this.
111 ini_set('session.cookie_path', $web_root ? $web_root : '/');
112 session_name("OpenEMR");
114 session_start();
116 // Set the site ID if required. This must be done before any database
117 // access is attempted.
118 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
119 if (!empty($_GET['site'])) {
120 $tmp = $_GET['site'];
121 } else {
122 if (empty($ignoreAuth)) {
123 // mdsupport - Don't die if logout menu link is called from expired session.
124 // Eliminate this code when close method is available for session management.
125 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
126 $GLOBALS['login_screen'] = "login_screen.php";
127 $srcdir = "../library";
128 require_once("$srcdir/auth.inc");
130 die("Site ID is missing from session data!");
133 $tmp = $_SERVER['HTTP_HOST'];
134 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
135 $tmp = "default";
139 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
140 die("Site ID '". text($tmp) . "' contains invalid characters.");
143 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
144 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
145 session_unset(); // clear session, clean logout
146 if (isset($landingpage) && !empty($landingpage)) {
147 // OpenEMR Patient Portal use
148 header('Location: index.php?site=' . urlencode($tmp));
149 } else {
150 // Main OpenEMR use
151 header('Location: ../login/login.php?site=' . urlencode($tmp)); // Assuming in the interface/main directory
154 exit;
157 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
158 $_SESSION['site_id'] = $tmp;
159 //error_log("Session site ID has been set to '$tmp'"); // debugging
163 // Set the site-specific directory path.
164 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
166 // Set a site-specific uri root path.
167 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
169 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
171 // Collecting the utf8 disable flag from the sqlconf.php file in order
172 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
173 // then set to iso-8859-1.
174 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
175 if (!$disable_utf8_flag) {
176 ini_set('default_charset', 'utf-8');
177 $HTML_CHARSET = "UTF-8";
178 mb_internal_encoding('UTF-8');
179 } else {
180 ini_set('default_charset', 'iso-8859-1');
181 $HTML_CHARSET = "ISO-8859-1";
182 mb_internal_encoding('ISO-8859-1');
185 // Root directory, relative to the webserver root:
186 $GLOBALS['rootdir'] = "$web_root/interface";
187 $rootdir = $GLOBALS['rootdir'];
188 // Absolute path to the source code include and headers file directory (Full path):
189 $GLOBALS['srcdir'] = "$webserver_root/library";
190 // Absolute path to the location of documentroot directory for use with include statements:
191 $GLOBALS['fileroot'] = "$webserver_root";
192 // Absolute path to the location of interface directory for use with include statements:
193 $include_root = "$webserver_root/interface";
194 // Absolute path to the location of documentroot directory for use with include statements:
195 $GLOBALS['webroot'] = $web_root;
197 // Static assets directory, relative to the webserver root.
198 // (it is very likely that this path will be changed in the future))
199 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
201 // Relative images directory, relative to the webserver root.
202 $GLOBALS['images_static_relative'] = "$web_root/public/images";
204 // Static images directory, absolute to the webserver root.
205 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
207 //Composer vendor directory, absolute to the webserver root.
208 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
209 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
210 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
211 $GLOBALS['incdir'] = $include_root;
212 // Location of the login screen file
213 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
215 // Variable set for Eligibility Verification [EDI-271] path
216 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
218 // Set and check that necessary writeable path exist for mPDF tool
219 $GLOBALS['MPDF_WRITE_DIR'] = $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp';
220 if (! is_dir($GLOBALS['MPDF_WRITE_DIR'])) {
221 mkdir($GLOBALS['MPDF_WRITE_DIR'], 0755, true);
224 // Includes composer autoload
225 // Note this also brings in following library files:
226 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
227 // library/formdata.inc.php - Include sanitization/checking functions (for security)
228 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
229 // library/formatting.inc.php - Includes functions for date/time internationalization and formatting
230 // library/date_functions.php - Includes functions for date internationalization
231 // library/validation/validate_core.php - Includes functions for page validation
232 // library/translation.inc.php - Includes translation functions
233 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
235 // Set up csrf token
236 // This is done in cases where it is not yet set for the session
237 // (note this is permanently done for the session in the main_screen.php script)
238 if (empty($_SESSION['csrf_token'])) {
239 $_SESSION['csrf_token'] = createCsrfToken();
243 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
245 * This allows to define a "development" environment which can then load up
246 * different variables and reporting/debugging functionality. Should be used in
247 * development only, not for production
249 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
251 if (file_exists("{$webserver_root}/.env")) {
252 $dotenv = new Dotenv($webserver_root);
253 $dotenv->load();
256 // @TODO This needs to be broken out to it's own function, but for time's sake
257 // @TODO putting it here until we land on a good place. RD 2017-05-02
259 $twigOptions = [
260 'debug' => false,
263 $twigLoader = new Twig_Loader_Filesystem();
264 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
266 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
267 $twigEnv->addExtension(new Twig_Extension_Debug());
270 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
271 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
272 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
273 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
274 return xl($string);
275 }));
277 /** Twig_Loader */
278 $GLOBALS['twigLoader'] = $twigLoader;
279 /** Twig_Environment */
280 $GLOBALS['twig'] = $twigEnv;
282 // This will open the openemr mysql connection.
283 require_once(dirname(__FILE__) . "/../library/sql.inc");
285 // Include the version file
286 require_once(dirname(__FILE__) . "/../version.php");
288 // The logging level for common/logging/logger.php
289 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
290 // - DEBUG/INFO are great for development
291 // - INFO/WARN/ERROR are great for production
292 // - TRACE is useful when debugging hard to spot bugs
293 $GLOBALS["log_level"] = "OFF";
295 try {
296 /** @var Kernel */
297 $GLOBALS["kernel"] = new Kernel();
298 } catch (\Exception $e) {
299 error_log($e->getMessage());
300 die();
303 // Should Doctrine make use of connection pooling? Database connection pooling is a method
304 // used to keep database connections open so they can be reused by others. (The only reason
305 // to not use connection pooling is if your server has limited resources.)
306 $GLOBALS["doctrine_connection_pooling"] = true;
308 // Defaults for specific applications.
309 $GLOBALS['weight_loss_clinic'] = false;
310 $GLOBALS['ippf_specific'] = false;
312 // Defaults for drugs and products.
313 $GLOBALS['inhouse_pharmacy'] = false;
314 $GLOBALS['sell_non_drug_products'] = 0;
316 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
317 if (!empty($glrow)) {
318 // Collect user specific settings from user_settings table.
320 $gl_user = array();
321 // Collect the user id first
322 $temp_authuserid = '';
323 if (!empty($_SESSION['authUserID'])) {
324 //Set the user id from the session variable
325 $temp_authuserid = $_SESSION['authUserID'];
326 } else {
327 if (!empty($_POST['authUser'])) {
328 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
329 if (!empty($temp_sql_ret['id'])) {
330 //Set the user id from the login variable
331 $temp_authuserid = $temp_sql_ret['id'];
336 if (!empty($temp_authuserid)) {
337 $glres_user = sqlStatement(
338 "SELECT `setting_label`, `setting_value` " .
339 "FROM `user_settings` " .
340 "WHERE `setting_user` = ? " .
341 "AND `setting_label` LIKE 'global:%'",
342 array($temp_authuserid)
344 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
345 //remove global_ prefix from label
346 $row['setting_label'] = substr($row['setting_label'], 7);
347 $gl_user[$iter]=$row;
351 // Set global parameters from the database globals table.
352 // Some parameters require custom handling.
354 $GLOBALS['language_menu_show'] = array();
355 $glres = sqlStatement(
356 "SELECT gl_name, gl_index, gl_value FROM globals " .
357 "ORDER BY gl_name, gl_index"
359 while ($glrow = sqlFetchArray($glres)) {
360 $gl_name = $glrow['gl_name'];
361 $gl_value = $glrow['gl_value'];
362 // Adjust for user specific settings
363 if (!empty($gl_user)) {
364 foreach ($gl_user as $setting) {
365 if ($gl_name == $setting['setting_label']) {
366 $gl_value = $setting['setting_value'];
371 if ($gl_name == 'language_menu_other') {
372 $GLOBALS['language_menu_show'][] = $gl_value;
373 } elseif ($gl_name == 'css_header') {
374 //Escape css file name using 'attr' for security (prevent XSS).
375 $GLOBALS[$gl_name] = $web_root.'/public/themes/'.attr($gl_value).'?v='.$v_js_includes;
376 $css_header = $GLOBALS[$gl_name];
377 $temp_css_theme_name = $gl_value;
378 } elseif ($gl_name == 'weekend_days') {
379 $GLOBALS[$gl_name] = explode(',', $gl_value);
380 } elseif ($gl_name == 'specific_application') {
381 if ($gl_value == '2') {
382 $GLOBALS['ippf_specific'] = true;
383 } elseif ($gl_value == '3') {
384 $GLOBALS['weight_loss_clinic'] = true;
386 } elseif ($gl_name == 'inhouse_pharmacy') {
387 if ($gl_value) {
388 $GLOBALS['inhouse_pharmacy'] = true;
391 if ($gl_value == '2') {
392 $GLOBALS['sell_non_drug_products'] = 1;
393 } elseif ($gl_value == '3') {
394 $GLOBALS['sell_non_drug_products'] = 2;
396 } elseif ($gl_name == 'gbl_time_zone') {
397 // The default PHP time zone is set here if it was specified, and is used
398 // as source data for the MySQL time zone here and in some other places
399 // where MySQL connections are opened.
400 if ($gl_value) {
401 date_default_timezone_set($gl_value);
404 // Synchronize MySQL time zone with PHP time zone.
405 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
406 } else {
407 $GLOBALS[$gl_name] = $gl_value;
411 // Language cleanup stuff.
412 $GLOBALS['language_menu_login'] = false;
413 if ((count($GLOBALS['language_menu_show']) > 1) || $GLOBALS['language_menu_showall']) {
414 $GLOBALS['language_menu_login'] = true;
417 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
418 // that may use this; note this global has been removed from the standard codebase.
419 $GLOBALS['concurrent_layout'] = 3;
421 // Additional logic to override theme name.
422 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
423 $rtl_override = false;
424 if (isset($_SESSION['language_direction'])) {
425 if ($_SESSION['language_direction'] == 'rtl' &&
426 !strpos($GLOBALS['css_header'], 'rtl') ) {
427 // the $css_header_value is set above
428 $rtl_override = true;
430 } elseif (isset($_SESSION['language_choice'])) {
431 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
432 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
433 if ($_SESSION['language_direction'] == 'rtl' &&
434 !strpos($GLOBALS['css_header'], 'rtl')) {
435 // the $css_header_value is set above
436 $rtl_override = true;
438 } else {
439 //$_SESSION['language_direction'] is not set, so will use the default language
440 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
442 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
443 // @todo eliminate 1 SQL query
444 $rtl_override = true;
449 // change theme name, if the override file exists.
450 if ($rtl_override) {
451 // the $css_header_value is set above
452 $new_theme = 'rtl_' . $temp_css_theme_name;
454 // Check file existance
455 if (file_exists($webserver_root.'/public/themes/'.$new_theme)) {
456 //Escape css file name using 'attr' for security (prevent XSS).
457 $GLOBALS['css_header'] = $web_root.'/public/themes/'.attr($new_theme).'?v='.$v_js_includes;
458 $css_header = $GLOBALS['css_header'];
459 } else {
460 // throw a warning if rtl'ed file does not exist.
461 error_log("Missing theme file ".text($webserver_root).'/public/themes/'.text($new_theme));
465 unset($temp_css_theme_name, $new_theme, $rtl_override);
466 // end of RTL section
469 // End of globals table processing.
470 } else {
471 // Temporary stuff to handle the case where the globals table does not
472 // exist yet. This will happen in sql_upgrade.php on upgrading to the
473 // first release containing this table.
474 $GLOBALS['language_menu_login'] = true;
475 $GLOBALS['language_menu_showall'] = true;
476 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
477 $GLOBALS['language_default'] = "English (Standard)";
478 $GLOBALS['translate_layout'] = true;
479 $GLOBALS['translate_lists'] = true;
480 $GLOBALS['translate_gacl_groups'] = true;
481 $GLOBALS['translate_form_titles'] = true;
482 $GLOBALS['translate_document_categories'] = true;
483 $GLOBALS['translate_appt_categories'] = true;
484 $timeout = 7200;
485 $openemr_name = 'OpenEMR';
486 $css_header = "$web_root/public/themes/style_default.css";
487 $GLOBALS['css_header'] = $css_header;
488 $GLOBALS['schedule_start'] = 8;
489 $GLOBALS['schedule_end'] = 17;
490 $GLOBALS['calendar_interval'] = 15;
491 $GLOBALS['phone_country_code'] = '1';
492 $GLOBALS['disable_non_default_groups'] = true;
493 $GLOBALS['ippf_specific'] = false;
496 // If >0 this will enforce a separate PHP session for each top-level
497 // browser window. You must log in separately for each. This is not
498 // thoroughly tested yet and some browsers might have trouble with it,
499 // so make it 0 if you must. Alternatively, you can set it to 2 to be
500 // notified when the session ID changes.
501 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
503 // Theme definition. All this stuff should be moved to CSS.
505 $top_bg_line = ' bgcolor="#dddddd" ';
506 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
507 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
508 // optimal size for the tiny logo is height 43 width 86 px
509 // inside the open emr they will be auto reduced
510 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
511 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
513 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
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 require_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
623 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
625 // turn off PHP compatibility warnings
626 ini_set("session.bug_compat_warn", "off");