Minor addition to message center help file (#1745)
[openemr.git] / interface / globals.php
blobd4223ad34aca1935f9ec1f56b563b5c56b440297
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\Common\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 //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.
18 $GLOBALS['debug_ssl_mysql_connection'] = false;
20 // Unless specified explicitly, apply Auth functions
21 if (!isset($ignoreAuth)) {
22 $ignoreAuth = false;
25 // Unless specified explicitly, caller is not offsite_portal and Auth is required
26 if (!isset($ignoreAuth_offsite_portal)) {
27 $ignoreAuth_offsite_portal = false;
30 // Same for onsite
31 if (!isset($ignoreAuth_onsite_portal_two)) {
32 $ignoreAuth_onsite_portal_two = false;
35 // Is this windows or non-windows? Create a boolean definition.
36 if (!defined('IS_WINDOWS')) {
37 define('IS_WINDOWS', (stripos(PHP_OS, 'WIN') === 0));
40 // Some important php.ini overrides. Defaults for these values are often
41 // too small. You might choose to adjust them further.
43 ini_set('session.gc_maxlifetime', '14400');
45 // The webserver_root and web_root are now automatically collected.
46 // If not working, can set manually below.
47 // Auto collect the full absolute directory path for openemr.
48 $webserver_root = dirname(dirname(__FILE__));
49 if (IS_WINDOWS) {
50 //convert windows path separators
51 $webserver_root = str_replace("\\", "/", $webserver_root);
54 // Collect the apache server document root (and convert to windows slashes, if needed)
55 $server_document_root = realpath($_SERVER['DOCUMENT_ROOT']);
56 if (IS_WINDOWS) {
57 //convert windows path separators
58 $server_document_root = str_replace("\\", "/", $server_document_root);
61 // Auto collect the relative html path, i.e. what you would type into the web
62 // browser after the server address to get to OpenEMR.
63 // This removes the leading portion of $webserver_root that it has in common with the web server's document
64 // root and assigns the result to $web_root. In addition to the common case where $webserver_root is
65 // /var/www/openemr and document root is /var/www, this also handles the case where document root is
66 // /var/www/html and there is an Apache "Alias" command that directs /openemr to /var/www/openemr.
67 $web_root = substr($webserver_root, strspn($webserver_root ^ $server_document_root, "\0"));
68 // Ensure web_root starts with a path separator
69 if (preg_match("/^[^\/]/", $web_root)) {
70 $web_root = "/".$web_root;
73 // The webserver_root and web_root are now automatically collected in
74 // real time per above code. If above is not working, can uncomment and
75 // set manually here:
76 // $webserver_root = "/var/www/openemr";
77 // $web_root = "/openemr";
80 // This is the directory that contains site-specific data. Change this
81 // only if you have some reason to.
82 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
84 // The session name names a cookie stored in the browser.
85 // Now that restore_session() is implemented in javaScript, session IDs are
86 // effectively saved in the top level browser window and there is no longer
87 // any need to change the session name for different OpenEMR instances.
88 // On 4/8/17, added cookie_path to improve security when using different
89 // OpenEMR instances on same server to prevent session conflicts; also
90 // modified interface/login/login.php and library/restoreSession.php to be
91 // consistent with this.
92 ini_set('session.cookie_path', $web_root ? $web_root : '/');
93 session_name("OpenEMR");
95 session_start();
97 // Set the site ID if required. This must be done before any database
98 // access is attempted.
99 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
100 if (!empty($_GET['site'])) {
101 $tmp = $_GET['site'];
102 } else {
103 if (empty($ignoreAuth)) {
104 // mdsupport - Don't die if logout menu link is called from expired session.
105 // Eliminate this code when close method is available for session management.
106 if ((isset($_GET['auth'])) && ($_GET['auth'] == "logout")) {
107 $GLOBALS['login_screen'] = "login_screen.php";
108 $srcdir = "../library";
109 include_once("$srcdir/auth.inc");
111 die("Site ID is missing from session data!");
114 $tmp = $_SERVER['HTTP_HOST'];
115 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
116 $tmp = "default";
120 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
121 die("Site ID '". htmlspecialchars($tmp, ENT_NOQUOTES) . "' contains invalid characters.");
124 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
125 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
126 session_unset(); // clear session, clean logout
127 if (isset($landingpage) && !empty($landingpage)) {
128 // OpenEMR Patient Portal use
129 header('Location: index.php?site='.$tmp);
130 } else {
131 // Main OpenEMR use
132 header('Location: ../login/login.php?site='.$tmp); // Assuming in the interface/main directory
135 exit;
138 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
139 $_SESSION['site_id'] = $tmp;
140 //error_log("Session site ID has been set to '$tmp'"); // debugging
144 // Set the site-specific directory path.
145 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
147 // Set a site-specific uri root path.
148 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
150 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
152 // Collecting the utf8 disable flag from the sqlconf.php file in order
153 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
154 // then set to iso-8859-1.
155 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
156 if (!$disable_utf8_flag) {
157 ini_set('default_charset', 'utf-8');
158 $HTML_CHARSET = "UTF-8";
159 mb_internal_encoding('UTF-8');
160 } else {
161 ini_set('default_charset', 'iso-8859-1');
162 $HTML_CHARSET = "ISO-8859-1";
163 mb_internal_encoding('ISO-8859-1');
166 // Root directory, relative to the webserver root:
167 $GLOBALS['rootdir'] = "$web_root/interface";
168 $rootdir = $GLOBALS['rootdir'];
169 // Absolute path to the source code include and headers file directory (Full path):
170 $GLOBALS['srcdir'] = "$webserver_root/library";
171 // Absolute path to the location of documentroot directory for use with include statements:
172 $GLOBALS['fileroot'] = "$webserver_root";
173 // Absolute path to the location of interface directory for use with include statements:
174 $include_root = "$webserver_root/interface";
175 // Absolute path to the location of documentroot directory for use with include statements:
176 $GLOBALS['webroot'] = $web_root;
178 // Static assets directory, relative to the webserver root.
179 // (it is very likely that this path will be changed in the future))
180 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
182 // Relative images directory, relative to the webserver root.
183 $GLOBALS['images_static_relative'] = "$web_root/public/images";
185 // Static images directory, absolute to the webserver root.
186 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
188 //Composer vendor directory, absolute to the webserver root.
189 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
190 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
191 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
192 $GLOBALS['incdir'] = $include_root;
193 // Location of the login screen file
194 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
196 // Variable set for Eligibility Verification [EDI-271] path
197 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
199 // Check necessary writeable paths exist for mPDF tool
200 if (is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/')) {
201 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/')) {
202 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755);
205 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/')) {
206 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
208 } else {
209 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755, true);
210 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
213 // Safe bet support directories exist, define them.
214 define("_MPDF_TEMP_PATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/');
215 define("_MPDF_TTFONTDATAPATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/');
217 // Includes composer autoload
218 // Note this also brings in following library files:
219 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
220 // library/formdata.inc.php - Include sanitization/checking functions (for security)
221 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
222 // library/date_functions.php - Includes functions for date internationalization
223 // library/validation/validate_core.php - Includes functions for page validation
224 // library/translation.inc.php - Includes translation functions
225 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
228 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
230 * This allows to define a "development" environment which can then load up
231 * different variables and reporting/debugging functionality. Should be used in
232 * development only, not for production
234 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
236 if (file_exists("{$webserver_root}/.env")) {
237 $dotenv = new Dotenv($webserver_root);
238 $dotenv->load();
241 // @TODO This needs to be broken out to it's own function, but for time's sake
242 // @TODO putting it here until we land on a good place. RD 2017-05-02
244 $twigOptions = [
245 'debug' => false,
248 $twigLoader = new Twig_Loader_Filesystem();
249 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
251 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
252 $twigEnv->addExtension(new Twig_Extension_Debug());
255 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
256 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
257 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
258 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
259 return xl($string);
260 }));
262 /** Twig_Loader */
263 $GLOBALS['twigLoader'] = $twigLoader;
264 /** Twig_Environment */
265 $GLOBALS['twig'] = $twigEnv;
267 // This will open the openemr mysql connection.
268 require_once(dirname(__FILE__) . "/../library/sql.inc");
270 // Include the version file
271 require_once(dirname(__FILE__) . "/../version.php");
273 // The logging level for common/logging/logger.php
274 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
275 // - DEBUG/INFO are great for development
276 // - INFO/WARN/ERROR are great for production
277 // - TRACE is useful when debugging hard to spot bugs
278 $GLOBALS["log_level"] = "OFF";
280 try {
281 /** @var Kernel */
282 $GLOBALS["kernel"] = new Kernel();
283 } catch (\Exception $e) {
284 error_log($e->getMessage());
285 die();
288 // Should Doctrine make use of connection pooling? Database connection pooling is a method
289 // used to keep database connections open so they can be reused by others. (The only reason
290 // to not use connection pooling is if your server has limited resources.)
291 $GLOBALS["doctrine_connection_pooling"] = true;
293 // Defaults for specific applications.
294 $GLOBALS['weight_loss_clinic'] = false;
295 $GLOBALS['ippf_specific'] = false;
297 // Defaults for drugs and products.
298 $GLOBALS['inhouse_pharmacy'] = false;
299 $GLOBALS['sell_non_drug_products'] = 0;
301 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
302 if (!empty($glrow)) {
303 // Collect user specific settings from user_settings table.
305 $gl_user = array();
306 // Collect the user id first
307 $temp_authuserid = '';
308 if (!empty($_SESSION['authUserID'])) {
309 //Set the user id from the session variable
310 $temp_authuserid = $_SESSION['authUserID'];
311 } else {
312 if (!empty($_POST['authUser'])) {
313 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
314 if (!empty($temp_sql_ret['id'])) {
315 //Set the user id from the login variable
316 $temp_authuserid = $temp_sql_ret['id'];
321 if (!empty($temp_authuserid)) {
322 $glres_user = sqlStatement(
323 "SELECT `setting_label`, `setting_value` " .
324 "FROM `user_settings` " .
325 "WHERE `setting_user` = ? " .
326 "AND `setting_label` LIKE 'global:%'",
327 array($temp_authuserid)
329 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
330 //remove global_ prefix from label
331 $row['setting_label'] = substr($row['setting_label'], 7);
332 $gl_user[$iter]=$row;
336 // Set global parameters from the database globals table.
337 // Some parameters require custom handling.
339 $GLOBALS['language_menu_show'] = array();
340 $glres = sqlStatement(
341 "SELECT gl_name, gl_index, gl_value FROM globals " .
342 "ORDER BY gl_name, gl_index"
344 while ($glrow = sqlFetchArray($glres)) {
345 $gl_name = $glrow['gl_name'];
346 $gl_value = $glrow['gl_value'];
347 // Adjust for user specific settings
348 if (!empty($gl_user)) {
349 foreach ($gl_user as $setting) {
350 if ($gl_name == $setting['setting_label']) {
351 $gl_value = $setting['setting_value'];
356 if ($gl_name == 'language_menu_other') {
357 $GLOBALS['language_menu_show'][] = $gl_value;
358 } elseif ($gl_name == 'css_header') {
359 //Escape css file name using 'attr' for security (prevent XSS).
360 $GLOBALS[$gl_name] = $rootdir.'/themes/'.attr($gl_value).'?v='.$v_js_includes;
361 $temp_css_theme_name = $gl_value;
362 } elseif ($gl_name == 'weekend_days') {
363 $GLOBALS[$gl_name] = explode(',', $gl_value);
364 } elseif ($gl_name == 'specific_application') {
365 if ($gl_value == '2') {
366 $GLOBALS['ippf_specific'] = true;
367 } elseif ($gl_value == '3') {
368 $GLOBALS['weight_loss_clinic'] = true;
370 } elseif ($gl_name == 'inhouse_pharmacy') {
371 if ($gl_value) {
372 $GLOBALS['inhouse_pharmacy'] = true;
375 if ($gl_value == '2') {
376 $GLOBALS['sell_non_drug_products'] = 1;
377 } elseif ($gl_value == '3') {
378 $GLOBALS['sell_non_drug_products'] = 2;
380 } elseif ($gl_name == 'gbl_time_zone') {
381 // The default PHP time zone is set here if it was specified, and is used
382 // as source data for the MySQL time zone here and in some other places
383 // where MySQL connections are opened.
384 if ($gl_value) {
385 date_default_timezone_set($gl_value);
388 // Synchronize MySQL time zone with PHP time zone.
389 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
390 } else {
391 $GLOBALS[$gl_name] = $gl_value;
395 // Language cleanup stuff.
396 $GLOBALS['language_menu_login'] = false;
397 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
398 $GLOBALS['language_menu_login'] = true;
401 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
402 // that may use this; note this global has been removed from the standard codebase.
403 $GLOBALS['concurrent_layout'] = 3;
405 // Additional logic to override theme name.
406 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
407 $rtl_override = false;
408 if (isset($_SESSION['language_direction'])) {
409 if ($_SESSION['language_direction'] == 'rtl' &&
410 !strpos($GLOBALS['css_header'], 'rtl') ) {
411 // the $css_header_value is set above
412 $rtl_override = true;
414 } elseif (isset($_SESSION['language_choice'])) {
415 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
416 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
417 if ($_SESSION['language_direction'] == 'rtl' &&
418 !strpos($GLOBALS['css_header'], 'rtl')) {
419 // the $css_header_value is set above
420 $rtl_override = true;
422 } else {
423 //$_SESSION['language_direction'] is not set, so will use the default language
424 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
426 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
427 // @todo eliminate 1 SQL query
428 $rtl_override = true;
433 // change theme name, if the override file exists.
434 if ($rtl_override) {
435 // the $css_header_value is set above
436 $new_theme = 'rtl_' . $temp_css_theme_name;
438 // Check file existance
439 if (file_exists($include_root.'/themes/'.$new_theme)) {
440 //Escape css file name using 'attr' for security (prevent XSS).
441 $GLOBALS['css_header'] = $rootdir.'/themes/'.attr($new_theme).'?v='.$v_js_includes;
442 } else {
443 // throw a warning if rtl'ed file does not exist.
444 error_log("Missing theme file ".text($include_root).'/themes/'.text($new_theme));
448 unset($temp_css_theme_name, $new_theme, $rtl_override);
449 // end of RTL section
452 // End of globals table processing.
453 } else {
454 // Temporary stuff to handle the case where the globals table does not
455 // exist yet. This will happen in sql_upgrade.php on upgrading to the
456 // first release containing this table.
457 $GLOBALS['language_menu_login'] = true;
458 $GLOBALS['language_menu_showall'] = true;
459 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
460 $GLOBALS['language_default'] = "English (Standard)";
461 $GLOBALS['translate_layout'] = true;
462 $GLOBALS['translate_lists'] = true;
463 $GLOBALS['translate_gacl_groups'] = true;
464 $GLOBALS['translate_form_titles'] = true;
465 $GLOBALS['translate_document_categories'] = true;
466 $GLOBALS['translate_appt_categories'] = true;
467 $timeout = 7200;
468 $openemr_name = 'OpenEMR';
469 $css_header = "$rootdir/themes/style_default.css";
470 $GLOBALS['css_header'] = $css_header;
471 $GLOBALS['schedule_start'] = 8;
472 $GLOBALS['schedule_end'] = 17;
473 $GLOBALS['calendar_interval'] = 15;
474 $GLOBALS['phone_country_code'] = '1';
475 $GLOBALS['disable_non_default_groups'] = true;
476 $GLOBALS['ippf_specific'] = false;
479 // If >0 this will enforce a separate PHP session for each top-level
480 // browser window. You must log in separately for each. This is not
481 // thoroughly tested yet and some browsers might have trouble with it,
482 // so make it 0 if you must. Alternatively, you can set it to 2 to be
483 // notified when the session ID changes.
484 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
486 // Theme definition. All this stuff should be moved to CSS.
488 $top_bg_line = ' bgcolor="#dddddd" ';
489 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
490 $bottom_bg_line = $top_bg_line;
491 $title_bg_line = ' bgcolor="#bbbbbb" ';
492 $nav_bg_line = ' bgcolor="#94d6e7" ';
493 $login_filler_line = ' bgcolor="#f7f0d5" ';
494 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
495 // optimal size for the tiny logo is height 43 width 86 px
496 // inside the open emr they will be auto reduced
497 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
498 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
500 $linepic = "$rootdir/pic/repeat_vline9.gif";
501 $table_bg = ' bgcolor="#cccccc" ';
502 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
503 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
504 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
505 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
506 // The height in pixels of the Logo bar at the top of the login page:
507 $GLOBALS['logoBarHeight'] = 110;
508 // The height in pixels of the Navigation bar:
509 $GLOBALS['navBarHeight'] = 22;
510 // The height in pixels of the Title bar:
511 $GLOBALS['titleBarHeight'] = 50;
513 // The assistant word, MORE printed next to titles that can be clicked:
514 // Note this label gets translated here via the xl function
515 // -if you don't want it translated, then strip the xl function away
516 $tmore = xl('(More)');
517 // The assistant word, BACK printed next to titles that return to previous screens:
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 $tback = xl('(Back)');
522 // This is the idle logout function:
523 // if a page has not been refreshed within this many seconds, the interface
524 // will return to the login page
525 if (!empty($special_timeout)) {
526 $timeout = intval($special_timeout);
529 $versionService = new \OpenEMR\Services\VersionService();
530 $version = $versionService->fetch();
532 if (!empty($version)) {
533 //Version tag
534 $patch_appending = "";
535 //Collected below function call to a variable, since unable to directly include
536 // function calls within empty() in php versions < 5.5 .
537 $version_getrealpatch = $version->getRealPatch();
538 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
539 $patch_appending = " (".$version->getRealPatch().")";
542 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
543 $openemr_version .= $version->getTag() . $patch_appending;
544 } else {
545 $openemr_version = xl('Unknown version');
548 $srcdir = $GLOBALS['srcdir'];
549 $login_screen = $GLOBALS['login_screen'];
550 $GLOBALS['css_header'] = $css_header;
551 $GLOBALS['backpic'] = $backpic;
553 // 1 = send email message to given id for Emergency Login user activation,
554 // else 0.
555 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
557 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
558 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
559 //functions, tables for de-identification(Mysql root user and password is required for successful
560 //execution of the de-identification upgrade script)
561 $GLOBALS['include_de_identification']=0;
562 // Include the authentication module code here, but the rule is
563 // if the file has the word "login" in the source code file name,
564 // don't include the authentication module - we do this to avoid
565 // include loops.
567 if (($ignoreAuth_offsite_portal === true) && ($GLOBALS['portal_offsite_enable'] == 1)) {
568 $ignoreAuth = true;
569 } elseif (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
570 $ignoreAuth = true;
573 if (!$ignoreAuth) {
574 include_once("$srcdir/auth.inc");
578 // This is the background color to apply to form fields that are searchable.
579 // Currently it is applicable only to the "Search or Add Patient" form.
580 $GLOBALS['layout_search_color'] = '#ff9919';
582 //EMAIL SETTINGS
583 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
586 //module configurations
587 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
588 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
589 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
591 // Don't change anything below this line. ////////////////////////////
593 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
595 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
596 $_SESSION['pid'] = $_GET['pid'];
597 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
598 $_SESSION['pid'] = $_POST['pid'];
601 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
602 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
603 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
605 //This is crucial for therapy groups and patients mechanisms to work together properly
606 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
607 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
609 // global interface function to format text length using ellipses
610 function strterm($string, $length)
612 if (strlen($string) >= ($length-3)) {
613 return substr($string, 0, $length-3) . "...";
614 } else {
615 return $string;
619 // Override temporary_files_dir if PHP >= 5.2.1.
620 if (version_compare(phpversion(), "5.2.1", ">=")) {
621 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
624 // turn off PHP compatibility warnings
625 ini_set("session.bug_compat_warn", "off");