Merge branch 'master' of git://github.com/openemr/openemr
[openemr.git] / interface / globals.php
blobb1c4721271a001741a4eaefb108a041ef2d036ea
1 <?php
2 /* $Id$ */
3 // ------------------------------------------------------------------------ //
4 // OpenEMR Electronic Medical Records System //
5 // Copyright (c) 2005-2010 oemr.org //
6 // <http://www.oemr.org/> //
7 // ------------------------------------------------------------------------ //
8 // This program is free software; you can redistribute it and/or modify //
9 // it under the terms of the GNU General Public License as published by //
10 // the Free Software Foundation; either version 2 of the License, or //
11 // (at your option) any later version. //
12 // //
13 // You may not change or alter any portion of this comment or credits //
14 // of supporting developers from this source code or any supporting //
15 // source code which is considered copyrighted (c) material of the //
16 // original comment or credit authors. //
17 // //
18 // This program is distributed in the hope that it will be useful, //
19 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
21 // GNU General Public License for more details. //
22 // //
23 // You should have received a copy of the GNU General Public License //
24 // along with this program; if not, write to the Free Software //
25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
26 // ------------------------------------------------------------------------ //
28 // Is this windows or non-windows? Create a boolean definition.
29 if (!defined('IS_WINDOWS'))
30 define('IS_WINDOWS', (stripos(PHP_OS,'WIN') === 0));
32 // Some important php.ini overrides. Defaults for these values are often
33 // too small. You might choose to adjust them further.
35 ini_set('memory_limit', '64M');
36 ini_set('session.gc_maxlifetime', '14400');
38 /* If the includer didn't specify, assume they want us to "fake" register_globals. */
39 if (!isset($fake_register_globals)) {
40 $fake_register_globals = TRUE;
43 /* Pages with "myadmin" in the URL don't need register_globals. */
44 $fake_register_globals =
45 $fake_register_globals && (strpos($_SERVER['REQUEST_URI'],"myadmin") === FALSE);
47 // Emulates register_globals = On. Moved to here from the bottom of this file
48 // to address security issues. Need to change everything requiring this!
49 if ($fake_register_globals) {
50 extract($_GET);
51 extract($_POST);
54 // This is for sanitization of all escapes.
55 // (ie. reversing magic quotes if it's set)
56 if ($sanitize_all_escapes) {
57 if (get_magic_quotes_gpc()) {
58 function undoMagicQuotes($array, $topLevel=true) {
59 $newArray = array();
60 foreach($array as $key => $value) {
61 if (!$topLevel) {
62 $key = stripslashes($key);
64 if (is_array($value)) {
65 $newArray[$key] = undoMagicQuotes($value, false);
67 else {
68 $newArray[$key] = stripslashes($value);
71 return $newArray;
73 $_GET = undoMagicQuotes($_GET);
74 $_POST = undoMagicQuotes($_POST);
75 $_COOKIE = undoMagicQuotes($_COOKIE);
76 $_REQUEST = undoMagicQuotes($_REQUEST);
80 require_once(dirname(__FILE__) . "/../includes/config.php");
83 // The webserver_root and web_root are now automatically collected.
84 // If not working, can set manually below.
85 // Auto collect the full absolute directory path for openemr.
86 $webserver_root = dirname(dirname(__FILE__));
87 if (IS_WINDOWS) {
88 //convert windows path separators
89 $webserver_root = str_replace("\\","/",$webserver_root);
91 // Auto collect the relative html path, i.e. what you would type into the web
92 // browser after the server address to get to OpenEMR.
93 $web_root = substr($webserver_root, strlen($_SERVER['DOCUMENT_ROOT']));
94 // Ensure web_root starts with a path separator
95 if (preg_match("/^[^\/]/",$web_root)) {
96 $web_root = "/".$web_root;
98 // The webserver_root and web_root are now automatically collected in
99 // real time per above code. If above is not working, can uncomment and
100 // set manually here:
101 // $webserver_root = "/var/www/openemr"
102 // $web_root = "/openemr"
105 // Collecting the utf8 disable flag from the sqlconf.php file in order
106 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
107 // then set to iso-8859-1.
108 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
109 if (!$disable_utf8_flag) {
110 ini_set('default_charset', 'utf-8');
111 $HTML_CHARSET = "UTF-8";
113 else {
114 ini_set('default_charset', 'iso-8859-1');
115 $HTML_CHARSET = "ISO-8859-1";
118 // Root directory, relative to the webserver root:
119 $GLOBALS['rootdir'] = "$web_root/interface";
120 $rootdir = $GLOBALS['rootdir'];
121 // Absolute path to the source code include and headers file directory (Full path):
122 $GLOBALS['srcdir'] = "$webserver_root/library";
123 // Absolute path to the location of documentroot directory for use with include statements:
124 $GLOBALS['fileroot'] = "$webserver_root";
125 // Absolute path to the location of interface directory for use with include statements:
126 $include_root = "$webserver_root/interface";
127 // Absolute path to the location of documentroot directory for use with include statements:
128 $GLOBALS['webroot'] = $web_root;
130 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
131 $GLOBALS['incdir'] = $include_root;
132 // Location of the login screen file
133 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
135 // Include the translation engine. This will also call sql.inc to
136 // open the openemr mysql connection.
137 include_once (dirname(__FILE__) . "/../library/translation.inc.php");
139 // Includes functions for date internationalization
140 include_once (dirname(__FILE__) . "/../library/date_functions.php");
142 // Defaults for specific applications.
143 $GLOBALS['athletic_team'] = false;
144 $GLOBALS['weight_loss_clinic'] = false;
145 $GLOBALS['ippf_specific'] = false;
146 $GLOBALS['cene_specific'] = false;
148 // Defaults for drugs and products.
149 $GLOBALS['inhouse_pharmacy'] = false;
150 $GLOBALS['sell_non_drug_products'] = 0;
152 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
153 if (!empty($glrow)) {
154 // Set global parameters from the database globals table.
155 // Some parameters require custom handling.
157 $GLOBALS['language_menu_show'] = array();
158 $glres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals " .
159 "ORDER BY gl_name, gl_index");
160 while ($glrow = sqlFetchArray($glres)) {
161 $gl_name = $glrow['gl_name'];
162 $gl_value = $glrow['gl_value'];
163 if ($gl_name == 'language_menu_other') {
164 $GLOBALS['language_menu_show'][] = $gl_value;
166 else if ($gl_name == 'css_header') {
167 $GLOBALS[$gl_name] = "$rootdir/themes/" . $gl_value;
169 else if ($gl_name == 'specific_application') {
170 if ($gl_value == '1') $GLOBALS['athletic_team'] = true;
171 else if ($gl_value == '2') $GLOBALS['ippf_specific'] = true;
172 else if ($gl_value == '3') $GLOBALS['weight_loss_clinic'] = true;
174 else if ($gl_name == 'inhouse_pharmacy') {
175 if ($gl_value) $GLOBALS['inhouse_pharmacy'] = true;
176 if ($gl_value == '2') $GLOBALS['sell_non_drug_products'] = 1;
177 else if ($gl_value == '3') $GLOBALS['sell_non_drug_products'] = 2;
179 else {
180 $GLOBALS[$gl_name] = $glrow['gl_value'];
183 // Language cleanup stuff.
184 $GLOBALS['language_menu_login'] = false;
185 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
186 $GLOBALS['language_menu_login'] = true;
189 // End of globals table processing.
191 else {
192 // Temporary stuff to handle the case where the globals table does not
193 // exist yet. This will happen in sql_upgrade.php on upgrading to the
194 // first release containing this table.
195 $GLOBALS['language_menu_login'] = true;
196 $GLOBALS['language_menu_showall'] = true;
197 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
198 $GLOBALS['language_default'] = "English (Standard)";
199 $GLOBALS['translate_layout'] = true;
200 $GLOBALS['translate_lists'] = true;
201 $GLOBALS['translate_gacl_groups'] = true;
202 $GLOBALS['translate_form_titles'] = true;
203 $GLOBALS['translate_document_categories'] = true;
204 $GLOBALS['translate_appt_categories'] = true;
205 $GLOBALS['concurrent_layout'] = 2;
206 $timeout = 7200;
207 $openemr_name = 'OpenEMR';
208 $css_header = "$rootdir/themes/style_sky_blue.css";
209 $GLOBALS['css_header'] = $css_header;
210 $GLOBALS['schedule_start'] = 8;
211 $GLOBALS['schedule_end'] = 17;
212 $GLOBALS['calendar_interval'] = 15;
213 $GLOBALS['phone_country_code'] = '1';
214 $GLOBALS['disable_non_default_groups'] = true;
215 $GLOBALS['ippf_specific'] = false;
219 // Lists and Layouts Control Section
222 // 'state_custom_addlist_widget'
223 // - If true, then will display a customized addlist widget for
224 // state list entries (will ask for title and abbreviation)
225 $GLOBALS['state_custom_addlist_widget'] = true;
226 $GLOBALS['state_list'] = "state";
227 $GLOBALS['country_list'] = "country";
229 // Option to set the top default window. By default, it is set
230 // to the calendar screen. The starting directory is
231 // interface/main/ , hence:
232 // The calendar screen is 'main_info.php' .
233 // The patient search/add screen is '../new/new.php' .
234 $GLOBALS['default_top_pane'] = 'main_info.php';
236 // Default category for find_patient screen
237 $GLOBALS['default_category'] = 5;
238 $GLOBALS['default_event_title'] = 'Office Visit';
240 // The session name appears in cookies stored in the browser. If you have
241 // multiple OpenEMR installations running on the same server, you should
242 // customize this name so they cannot interfere with each other.
244 // Also, if modify session_name, then need to place the identical name in
245 // the phpmyadmin file here: openemr/phpmyadmin/libraries/session.inc.php
246 // at line 71. This was required after embedded new phpmyadmin version on
247 // 05-12-2009 by Brady. Hopefully will figure out a more appropriate fix.
248 session_name("OpenEMR");
250 session_start();
252 // If >0 this will enforce a separate PHP session for each top-level
253 // browser window. You must log in separately for each. This is not
254 // thoroughly tested yet and some browsers might have trouble with it,
255 // so make it 0 if you must. Alternatively, you can set it to 2 to be
256 // notified when the session ID changes.
257 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
259 // Theme definition. All this stuff should be moved to CSS.
261 if ($GLOBALS['concurrent_layout']) {
262 $top_bg_line = ' bgcolor="#dddddd" ';
263 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
264 $bottom_bg_line = $top_bg_line;
265 $title_bg_line = ' bgcolor="#bbbbbb" ';
266 $nav_bg_line = ' bgcolor="#94d6e7" ';
267 } else {
268 $top_bg_line = ' bgcolor="#94d6e7" ';
269 $GLOBALS['style']['BGCOLOR2'] = "#94d6e7";
270 $bottom_bg_line = ' background="'.$rootdir.'/pic/aquabg.gif" ';
271 $title_bg_line = ' bgcolor="#aaffff" ';
272 $nav_bg_line = ' bgcolor="#94d6e7" ';
274 $login_filler_line = ' bgcolor="#f7f0d5" ';
275 $login_body_line = ' background="'.$rootdir.'/pic/aquabg.gif" ';
276 $logocode="<img src='$rootdir/pic/logo_sky.gif'>";
277 $linepic = "$rootdir/pic/repeat_vline9.gif";
278 $table_bg = ' bgcolor="#cccccc" ';
279 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
280 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
281 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
282 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
283 // The height in pixels of the Logo bar at the top of the login page:
284 $GLOBALS['logoBarHeight'] = 110;
285 // The height in pixels of the Navigation bar:
286 $GLOBALS['navBarHeight'] = 22;
287 // The height in pixels of the Title bar:
288 $GLOBALS['titleBarHeight'] = 20;
290 // The assistant word, MORE printed next to titles that can be clicked:
291 // Note this label gets translated here via the xl function
292 // -if you don't want it translated, then strip the xl function away
293 $tmore = xl('(More)');
294 // The assistant word, BACK printed next to titles that return to previous screens:
295 // Note this label gets translated here via the xl function
296 // -if you don't want it translated, then strip the xl function away
297 $tback = xl('(Back)');
299 // This is the idle logout function:
300 // if a page has not been refreshed within this many seconds, the interface
301 // will return to the login page
302 if (!empty($special_timeout)) {
303 $timeout = intval($special_timeout);
306 //Version tags
308 $v_major = '4';
309 $v_minor = '0';
310 $v_patch = '0';
311 $tag = '-dev'; // minor revision number, should be empty for production releases
313 $openemr_version = "$v_major.$v_minor.$v_patch".$tag; // Version tag used by program
315 $srcdir = $GLOBALS['srcdir'];
316 $login_screen = $GLOBALS['login_screen'];
317 $GLOBALS['css_header'] = $css_header;
318 $GLOBALS['backpic'] = $backpic;
320 // 1 = send email message to given id for Emergency Login user activation,
321 // else 0.
322 $GLOBALS['Emergency_Login_email'] = $GLOBALS['Emergency_Login_email_id'] ? 1 : 0;
324 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
325 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
326 //functions, tables for de-identification(Mysql root user and password is required for successful
327 //execution of the de-identification upgrade script)
328 $GLOBALS['include_de_identification']=0;
329 // Include the authentication module code here, but the rule is
330 // if the file has the word "login" in the source code file name,
331 // don't include the authentication module - we do this to avoid
332 // include loops.
334 if (!$ignoreAuth) {
335 include_once("$srcdir/auth.inc");
338 // If you do not want your accounting system to have a customer added to it
339 // for each insurance company, then set this to true. SQL-Ledger currently
340 // (2005-03-21) does nothing useful with insurance companies as customers.
341 $GLOBALS['insurance_companies_are_not_customers'] = true;
343 // This is the background color to apply to form fields that are searchable.
344 // Currently it is applicable only to the "Search or Add Patient" form.
345 $GLOBALS['layout_search_color'] = '#ffff55';
347 //EMAIL SETTINGS
348 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
350 // The following credentials are provided by OpenEMR Support LLC for testing.
351 // When you sign up with their Lab Exchange service, they will provide you with your own credentials.
353 /* use this for testing
354 $LAB_EXCHANGE_SITEID = "3";
355 $LAB_EXCHANGE_TOKEN = "12345";
356 $LAB_EXCHANGE_ENDPOINT = "https://openemrsupport.com:29443/len/api";
359 $LAB_EXCHANGE_SITEID = "";
360 $LAB_EXCHANGE_TOKEN = "";
361 $LAB_EXCHANGE_ENDPOINT = "";
363 // If you want Hylafax support then uncomment and customize the following
364 // statements, and also customize custom/faxcover.txt:
366 // $GLOBALS['hylafax_server'] = 'localhost';
367 // $GLOBALS['hylafax_basedir'] = '/var/spool/fax';
368 // $GLOBALS['hylafax_enscript'] = 'enscript -M Letter -B -e^ --margins=36:36:36:36';
370 // For scanner support, uncomment and customize the following. This is
371 // the directory in which scanned-in documents may be found, and may for
372 // example be a smbfs-mounted share from the PC supporting the scanner:
374 // $GLOBALS['scanner_output_directory'] = '/mnt/scan_docs';
376 // Customize these if you are using SQL-Ledger with OpenEMR, or if you are
377 // going to run sl_convert.php to convert from SQL-Ledger.
379 $sl_cash_acc = '1060'; // sql-ledger account number for checking account
380 $sl_ar_acc = '1200'; // sql-ledger account number for accounts receivable
381 $sl_income_acc = '4320'; // sql-ledger account number for medical services income
382 $sl_services_id = 'MS'; // sql-ledger parts table id for medical services
383 $sl_dbname = 'sql-ledger'; // sql-ledger database name
384 $sl_dbuser = 'sql-ledger'; // sql-ledger database login name
385 $sl_dbpass = 'secret'; // sql-ledger database login password
387 ///////////////////////// AUDIT LOGGING CONFIG ////////////////
388 //$GLOBALS["enable_auditlog"]=0 is to off the logging feature in openemr
389 //$GLOBALS["enable_auditlog"]=1 is to on the logging feature in openemr
390 //patient-record:- set 1 (0 to off) to log the patient related activites like creation of new patient, encounters, history//etc.
391 //scheduling:- set 1 (0 to off) to log the patient related scheduling like Appointments.
392 //query:- set 1 (0 to off) to log all SQL SELECT queries.
393 //order:- set 1 (0 to off) to log an orders like medical service or medical item (like a prescription).
394 //security-administration:- set 1 to (0 to off) to log events such as creating/updating users/facility etc.
395 //backup:- set 1 (0 to off) to log backup related activites.
396 $GLOBALS["enable_auditlog"]=1;
397 $GLOBALS["audit_events"]=array("patient-record"=>1,
398 "scheduling"=>1,
399 "query"=>0,
400 "order"=>1,
401 "security-administration"=>1,
402 "backup"=>1,
405 // Configure the settings below to enable Audit Trail and Node Authentication (ATNA).
406 // See RFC 3881, RFC 5424, RFC 5425 for details.
407 // atna_audit_host = The hostname of the audit repository machine
408 // atna_audit_port = Listening port of the RFC 5425 TLS syslog server
409 // atna_audit_localcert - Certificate to send to RFC 5425 TLS syslog server
410 // atna_audit_cacert - CA Certificate for verifying the RFC 5425 TLS syslog server
411 $GLOBALS['atna_audit_host'] = '';
412 $GLOBALS['atna_audit_port'] = 6514;
413 $GLOBALS['atna_audit_localcert'] = '';
414 $GLOBALS['atna_audit_cacert'] = '';
415 //////////////////////////////////////////////////////////////////
417 // Don't change anything below this line. ////////////////////////////
419 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
421 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
422 $_SESSION['pid'] = $_GET['pid'];
424 elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
425 $_SESSION['pid'] = $_POST['pid'];
427 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
428 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
429 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
431 // global interface function to format text length using ellipses
432 function strterm($string,$length) {
433 if (strlen($string) >= ($length-3)) {
434 return substr($string,0,$length-3) . "...";
435 } else {
436 return $string;
440 // Override temporary_files_dir if PHP >= 5.2.1.
441 if (version_compare(phpversion(), "5.2.1", ">=")) {
442 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(),'/');
445 // turn off PHP compatibility warnings
446 ini_set("session.bug_compat_warn","off");
448 //////////////////////////////////////////////////////////////////