change viewer calling paths (#1410)
[openemr.git] / interface / globals.php
blob34f2724190685ea8a777594e1e4ea392ae8f8feb
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 die("Site ID is missing from session data!");
107 $tmp = $_SERVER['HTTP_HOST'];
108 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) {
109 $tmp = "default";
113 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp)) {
114 die("Site ID '". htmlspecialchars($tmp, ENT_NOQUOTES) . "' contains invalid characters.");
117 if (isset($_SESSION['site_id']) && ($_SESSION['site_id'] != $tmp)) {
118 // This is to prevent using session to penetrate other OpenEMR instances within same multisite module
119 session_unset(); // clear session, clean logout
120 if (isset($landingpage) && !empty($landingpage)) {
121 // OpenEMR Patient Portal use
122 header('Location: index.php?site='.$tmp);
123 } else {
124 // Main OpenEMR use
125 header('Location: ../login/login.php?site='.$tmp); // Assuming in the interface/main directory
128 exit;
131 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
132 $_SESSION['site_id'] = $tmp;
133 //error_log("Session site ID has been set to '$tmp'"); // debugging
137 // Set the site-specific directory path.
138 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
140 // Set a site-specific uri root path.
141 $GLOBALS['OE_SITE_WEBROOT'] = $web_root . "/sites/" . $_SESSION['site_id'];
143 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
145 // Collecting the utf8 disable flag from the sqlconf.php file in order
146 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
147 // then set to iso-8859-1.
148 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
149 if (!$disable_utf8_flag) {
150 ini_set('default_charset', 'utf-8');
151 $HTML_CHARSET = "UTF-8";
152 mb_internal_encoding('UTF-8');
153 } else {
154 ini_set('default_charset', 'iso-8859-1');
155 $HTML_CHARSET = "ISO-8859-1";
156 mb_internal_encoding('ISO-8859-1');
159 // Root directory, relative to the webserver root:
160 $GLOBALS['rootdir'] = "$web_root/interface";
161 $rootdir = $GLOBALS['rootdir'];
162 // Absolute path to the source code include and headers file directory (Full path):
163 $GLOBALS['srcdir'] = "$webserver_root/library";
164 // Absolute path to the location of documentroot directory for use with include statements:
165 $GLOBALS['fileroot'] = "$webserver_root";
166 // Absolute path to the location of interface directory for use with include statements:
167 $include_root = "$webserver_root/interface";
168 // Absolute path to the location of documentroot directory for use with include statements:
169 $GLOBALS['webroot'] = $web_root;
171 // Static assets directory, relative to the webserver root.
172 // (it is very likely that this path will be changed in the future))
173 $GLOBALS['assets_static_relative'] = "$web_root/public/assets";
175 // Relative images directory, relative to the webserver root.
176 $GLOBALS['images_static_relative'] = "$web_root/public/images";
178 // Static images directory, absolute to the webserver root.
179 $GLOBALS['images_static_absolute'] = "$webserver_root/public/images";
181 //Composer vendor directory, absolute to the webserver root.
182 $GLOBALS['vendor_dir'] = "$webserver_root/vendor";
183 $GLOBALS['fonts_dir'] = "{$web_root}/public/fonts";
184 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
185 $GLOBALS['incdir'] = $include_root;
186 // Location of the login screen file
187 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
189 // Variable set for Eligibility Verification [EDI-271] path
190 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
192 // Check necessary writeable paths exist for mPDF tool
193 if (is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/')) {
194 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/')) {
195 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755);
198 if (! is_dir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/')) {
199 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
201 } else {
202 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/', 0755, true);
203 mkdir($GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/', 0755);
206 // Safe bet support directories exist, define them.
207 define("_MPDF_TEMP_PATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/pdf_tmp/');
208 define("_MPDF_TTFONTDATAPATH", $GLOBALS['OE_SITE_DIR'] . '/documents/mpdf/ttfontdata/');
210 // Includes composer autoload
211 // Note this also brings in following library files:
212 // library/htmlspecialchars.inc.php - Include convenience functions with shorter names than "htmlspecialchars" (for security)
213 // library/formdata.inc.php - Include sanitization/checking functions (for security)
214 // library/sanitize.inc.php - Include sanitization/checking functions (for security)
215 // library/date_functions.php - Includes functions for date internationalization
216 // library/validation/validate_core.php - Includes functions for page validation
217 // library/translation.inc.php - Includes translation functions
218 require_once $GLOBALS['vendor_dir'] ."/autoload.php";
221 * @var Dotenv Allow a `.env` file to be read in and applied as $_SERVER variables.
223 * This allows to define a "development" environment which can then load up
224 * different variables and reporting/debugging functionality. Should be used in
225 * development only, not for production
227 * @link http://open-emr.org/wiki/index.php/Dotenv_Usage
229 if (file_exists("{$webserver_root}/.env")) {
230 $dotenv = new Dotenv($webserver_root);
231 $dotenv->load();
234 // @TODO This needs to be broken out to it's own function, but for time's sake
235 // @TODO putting it here until we land on a good place. RD 2017-05-02
237 $twigOptions = [
238 'debug' => false,
241 $twigLoader = new Twig_Loader_Filesystem();
242 $twigEnv = new Twig_Environment($twigLoader, $twigOptions);
244 if (array_key_exists('debug', $twigOptions) && $twigOptions['debug'] == true) {
245 $twigEnv->addExtension(new Twig_Extension_Debug());
248 $twigEnv->addGlobal('assets_dir', $GLOBALS['assets_static_relative']);
249 $twigEnv->addGlobal('srcdir', $GLOBALS['srcdir']);
250 $twigEnv->addGlobal('rootdir', $GLOBALS['rootdir']);
251 $twigEnv->addFilter(new Twig_SimpleFilter('translate', function ($string) {
252 return xl($string);
253 }));
255 /** Twig_Loader */
256 $GLOBALS['twigLoader'] = $twigLoader;
257 /** Twig_Environment */
258 $GLOBALS['twig'] = $twigEnv;
260 // This will open the openemr mysql connection.
261 require_once(dirname(__FILE__) . "/../library/sql.inc");
263 // Include the version file
264 require_once(dirname(__FILE__) . "/../version.php");
266 // The logging level for common/logging/logger.php
267 // Value can be TRACE, DEBUG, INFO, WARN, ERROR, or OFF:
268 // - DEBUG/INFO are great for development
269 // - INFO/WARN/ERROR are great for production
270 // - TRACE is useful when debugging hard to spot bugs
271 $GLOBALS["log_level"] = "OFF";
273 try {
274 /** @var Kernel */
275 $GLOBALS["kernel"] = new Kernel();
276 } catch (\Exception $e) {
277 error_log($e->getMessage());
278 die();
281 // Should Doctrine make use of connection pooling? Database connection pooling is a method
282 // used to keep database connections open so they can be reused by others. (The only reason
283 // to not use connection pooling is if your server has limited resources.)
284 $GLOBALS["doctrine_connection_pooling"] = true;
286 // Defaults for specific applications.
287 $GLOBALS['weight_loss_clinic'] = false;
288 $GLOBALS['ippf_specific'] = false;
290 // Defaults for drugs and products.
291 $GLOBALS['inhouse_pharmacy'] = false;
292 $GLOBALS['sell_non_drug_products'] = 0;
294 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
295 if (!empty($glrow)) {
296 // Collect user specific settings from user_settings table.
298 $gl_user = array();
299 // Collect the user id first
300 $temp_authuserid = '';
301 if (!empty($_SESSION['authUserID'])) {
302 //Set the user id from the session variable
303 $temp_authuserid = $_SESSION['authUserID'];
304 } else {
305 if (!empty($_POST['authUser'])) {
306 $temp_sql_ret = sqlQuery("SELECT `id` FROM `users` WHERE `username` = ?", array($_POST['authUser']));
307 if (!empty($temp_sql_ret['id'])) {
308 //Set the user id from the login variable
309 $temp_authuserid = $temp_sql_ret['id'];
314 if (!empty($temp_authuserid)) {
315 $glres_user = sqlStatement(
316 "SELECT `setting_label`, `setting_value` " .
317 "FROM `user_settings` " .
318 "WHERE `setting_user` = ? " .
319 "AND `setting_label` LIKE 'global:%'",
320 array($temp_authuserid)
322 for ($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
323 //remove global_ prefix from label
324 $row['setting_label'] = substr($row['setting_label'], 7);
325 $gl_user[$iter]=$row;
329 // Set global parameters from the database globals table.
330 // Some parameters require custom handling.
332 $GLOBALS['language_menu_show'] = array();
333 $glres = sqlStatement(
334 "SELECT gl_name, gl_index, gl_value FROM globals " .
335 "ORDER BY gl_name, gl_index"
337 while ($glrow = sqlFetchArray($glres)) {
338 $gl_name = $glrow['gl_name'];
339 $gl_value = $glrow['gl_value'];
340 // Adjust for user specific settings
341 if (!empty($gl_user)) {
342 foreach ($gl_user as $setting) {
343 if ($gl_name == $setting['setting_label']) {
344 $gl_value = $setting['setting_value'];
349 if ($gl_name == 'language_menu_other') {
350 $GLOBALS['language_menu_show'][] = $gl_value;
351 } elseif ($gl_name == 'css_header') {
352 //Escape css file name using 'attr' for security (prevent XSS).
353 $GLOBALS[$gl_name] = $rootdir.'/themes/'.attr($gl_value).'?v='.$v_js_includes;
354 $temp_css_theme_name = $gl_value;
355 } elseif ($gl_name == 'weekend_days') {
356 $GLOBALS[$gl_name] = explode(',', $gl_value);
357 } elseif ($gl_name == 'specific_application') {
358 if ($gl_value == '2') {
359 $GLOBALS['ippf_specific'] = true;
360 } elseif ($gl_value == '3') {
361 $GLOBALS['weight_loss_clinic'] = true;
363 } elseif ($gl_name == 'inhouse_pharmacy') {
364 if ($gl_value) {
365 $GLOBALS['inhouse_pharmacy'] = true;
368 if ($gl_value == '2') {
369 $GLOBALS['sell_non_drug_products'] = 1;
370 } elseif ($gl_value == '3') {
371 $GLOBALS['sell_non_drug_products'] = 2;
373 } elseif ($gl_name == 'gbl_time_zone') {
374 // The default PHP time zone is set here if it was specified, and is used
375 // as source data for the MySQL time zone here and in some other places
376 // where MySQL connections are opened.
377 if ($gl_value) {
378 date_default_timezone_set($gl_value);
381 // Synchronize MySQL time zone with PHP time zone.
382 sqlStatement("SET time_zone = ?", array((new DateTime())->format("P")));
383 } else {
384 $GLOBALS[$gl_name] = $gl_value;
388 // Language cleanup stuff.
389 $GLOBALS['language_menu_login'] = false;
390 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
391 $GLOBALS['language_menu_login'] = true;
394 // Added this $GLOBALS['concurrent_layout'] set to 3 in order to support legacy forms
395 // that may use this; note this global has been removed from the standard codebase.
396 $GLOBALS['concurrent_layout'] = 3;
398 // Additional logic to override theme name.
399 // For RTL languages we substitute the theme name with the name of RTL-adapted CSS file.
400 $rtl_override = false;
401 if (isset($_SESSION['language_direction'])) {
402 if ($_SESSION['language_direction'] == 'rtl' &&
403 !strpos($GLOBALS['css_header'], 'rtl') ) {
404 // the $css_header_value is set above
405 $rtl_override = true;
407 } elseif (isset($_SESSION['language_choice'])) {
408 //this will support the onsite patient portal which will have a language choice but not yet a set language direction
409 $_SESSION['language_direction'] = getLanguageDir($_SESSION['language_choice']);
410 if ($_SESSION['language_direction'] == 'rtl' &&
411 !strpos($GLOBALS['css_header'], 'rtl')) {
412 // the $css_header_value is set above
413 $rtl_override = true;
415 } else {
416 //$_SESSION['language_direction'] is not set, so will use the default language
417 $default_lang_id = sqlQuery('SELECT lang_id FROM lang_languages WHERE lang_description = ?', array($GLOBALS['language_default']));
419 if (getLanguageDir($default_lang_id['lang_id']) === 'rtl' && !strpos($GLOBALS['css_header'], 'rtl')) {
420 // @todo eliminate 1 SQL query
421 $rtl_override = true;
426 // change theme name, if the override file exists.
427 if ($rtl_override) {
428 // the $css_header_value is set above
429 $new_theme = 'rtl_' . $temp_css_theme_name;
431 // Check file existance
432 if (file_exists($include_root.'/themes/'.$new_theme)) {
433 //Escape css file name using 'attr' for security (prevent XSS).
434 $GLOBALS['css_header'] = $rootdir.'/themes/'.attr($new_theme).'?v='.$v_js_includes;
435 } else {
436 // throw a warning if rtl'ed file does not exist.
437 error_log("Missing theme file ".text($include_root).'/themes/'.text($new_theme));
441 unset($temp_css_theme_name, $new_theme, $rtl_override);
442 // end of RTL section
445 // End of globals table processing.
446 } else {
447 // Temporary stuff to handle the case where the globals table does not
448 // exist yet. This will happen in sql_upgrade.php on upgrading to the
449 // first release containing this table.
450 $GLOBALS['language_menu_login'] = true;
451 $GLOBALS['language_menu_showall'] = true;
452 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
453 $GLOBALS['language_default'] = "English (Standard)";
454 $GLOBALS['translate_layout'] = true;
455 $GLOBALS['translate_lists'] = true;
456 $GLOBALS['translate_gacl_groups'] = true;
457 $GLOBALS['translate_form_titles'] = true;
458 $GLOBALS['translate_document_categories'] = true;
459 $GLOBALS['translate_appt_categories'] = true;
460 $timeout = 7200;
461 $openemr_name = 'OpenEMR';
462 $css_header = "$rootdir/themes/style_default.css";
463 $GLOBALS['css_header'] = $css_header;
464 $GLOBALS['schedule_start'] = 8;
465 $GLOBALS['schedule_end'] = 17;
466 $GLOBALS['calendar_interval'] = 15;
467 $GLOBALS['phone_country_code'] = '1';
468 $GLOBALS['disable_non_default_groups'] = true;
469 $GLOBALS['ippf_specific'] = false;
472 // If >0 this will enforce a separate PHP session for each top-level
473 // browser window. You must log in separately for each. This is not
474 // thoroughly tested yet and some browsers might have trouble with it,
475 // so make it 0 if you must. Alternatively, you can set it to 2 to be
476 // notified when the session ID changes.
477 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
479 // Theme definition. All this stuff should be moved to CSS.
481 $top_bg_line = ' bgcolor="#dddddd" ';
482 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
483 $bottom_bg_line = $top_bg_line;
484 $title_bg_line = ' bgcolor="#bbbbbb" ';
485 $nav_bg_line = ' bgcolor="#94d6e7" ';
486 $login_filler_line = ' bgcolor="#f7f0d5" ';
487 $logocode = "<img class='img-responsive center-block' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/login_logo.gif'>";
488 // optimal size for the tiny logo is height 43 width 86 px
489 // inside the open emr they will be auto reduced
490 $tinylogocode1 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_1.png'>";
491 $tinylogocode2 = "<img class='tinylogopng' src='" . $GLOBALS['OE_SITE_WEBROOT'] . "/images/logo_2.png'>";
493 $linepic = "$rootdir/pic/repeat_vline9.gif";
494 $table_bg = ' bgcolor="#cccccc" ';
495 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
496 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
497 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
498 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
499 // The height in pixels of the Logo bar at the top of the login page:
500 $GLOBALS['logoBarHeight'] = 110;
501 // The height in pixels of the Navigation bar:
502 $GLOBALS['navBarHeight'] = 22;
503 // The height in pixels of the Title bar:
504 $GLOBALS['titleBarHeight'] = 50;
506 // The assistant word, MORE printed next to titles that can be clicked:
507 // Note this label gets translated here via the xl function
508 // -if you don't want it translated, then strip the xl function away
509 $tmore = xl('(More)');
510 // The assistant word, BACK printed next to titles that return to previous screens:
511 // Note this label gets translated here via the xl function
512 // -if you don't want it translated, then strip the xl function away
513 $tback = xl('(Back)');
515 // This is the idle logout function:
516 // if a page has not been refreshed within this many seconds, the interface
517 // will return to the login page
518 if (!empty($special_timeout)) {
519 $timeout = intval($special_timeout);
522 $versionService = new \OpenEMR\Services\VersionService();
523 $version = $versionService->fetch();
525 if (!empty($version)) {
526 //Version tag
527 $patch_appending = "";
528 //Collected below function call to a variable, since unable to directly include
529 // function calls within empty() in php versions < 5.5 .
530 $version_getrealpatch = $version->getRealPatch();
531 if (($version->getRealPatch() != '0') && (!(empty($version_getrealpatch)))) {
532 $patch_appending = " (".$version->getRealPatch().")";
535 $openemr_version = $version->getMajor() . "." . $version->getMinor() . "." . $version->getPatch();
536 $openemr_version .= $version->getTag() . $patch_appending;
537 } else {
538 $openemr_version = xl('Unknown version');
541 $srcdir = $GLOBALS['srcdir'];
542 $login_screen = $GLOBALS['login_screen'];
543 $GLOBALS['css_header'] = $css_header;
544 $GLOBALS['backpic'] = $backpic;
546 // 1 = send email message to given id for Emergency Login user activation,
547 // else 0.
548 $GLOBALS['Emergency_Login_email'] = empty($GLOBALS['Emergency_Login_email_id']) ? 0 : 1;
550 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
551 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
552 //functions, tables for de-identification(Mysql root user and password is required for successful
553 //execution of the de-identification upgrade script)
554 $GLOBALS['include_de_identification']=0;
555 // Include the authentication module code here, but the rule is
556 // if the file has the word "login" in the source code file name,
557 // don't include the authentication module - we do this to avoid
558 // include loops.
560 if (($ignoreAuth_offsite_portal === true) && ($GLOBALS['portal_offsite_enable'] == 1)) {
561 $ignoreAuth = true;
562 } elseif (($ignoreAuth_onsite_portal_two === true) && ($GLOBALS['portal_onsite_two_enable'] == 1)) {
563 $ignoreAuth = true;
566 if (!$ignoreAuth) {
567 include_once("$srcdir/auth.inc");
571 // This is the background color to apply to form fields that are searchable.
572 // Currently it is applicable only to the "Search or Add Patient" form.
573 $GLOBALS['layout_search_color'] = '#ff9919';
575 //EMAIL SETTINGS
576 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
579 //module configurations
580 $GLOBALS['baseModDir'] = "interface/modules/"; //default path of modules
581 $GLOBALS['customModDir'] = "custom_modules"; //non zend modules
582 $GLOBALS['zendModDir'] = "zend_modules"; //zend modules
584 // Don't change anything below this line. ////////////////////////////
586 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
588 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
589 $_SESSION['pid'] = $_GET['pid'];
590 } elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
591 $_SESSION['pid'] = $_POST['pid'];
594 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
595 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
596 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
598 //This is crucial for therapy groups and patients mechanisms to work together properly
599 $attendant_type = (empty($pid) && isset($_SESSION['therapy_group'])) ? 'gid' : 'pid';
600 $therapy_group = (empty($pid) && isset($_SESSION['therapy_group'])) ? $_SESSION['therapy_group'] : 0;
602 // global interface function to format text length using ellipses
603 function strterm($string, $length)
605 if (strlen($string) >= ($length-3)) {
606 return substr($string, 0, $length-3) . "...";
607 } else {
608 return $string;
612 // Override temporary_files_dir if PHP >= 5.2.1.
613 if (version_compare(phpversion(), "5.2.1", ">=")) {
614 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(), '/');
617 // turn off PHP compatibility warnings
618 ini_set("session.bug_compat_warn", "off");