Initial revision
[openemr.git] / interface / globals.php
blob090b7780d94e8b3ca122fcade8a5f618aef093d3
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 // Emulates register_globals = On. Moved to here from the bottom of this file
39 // to address security issues. Need to change everything requiring this!
40 $ps = strpos($_SERVER['REQUEST_URI'],"myadmin");
41 if ($ps === false) {
42 extract($_GET);
43 extract($_POST);
46 require_once(dirname(__FILE__) . "/../includes/config.php");
49 // The webserver_root and web_root are now automatically collected.
50 // If not working, can set manually below.
51 // Auto collect the full absolute directory path for openemr.
52 $webserver_root = dirname(dirname(__FILE__));
53 if (IS_WINDOWS) {
54 //convert windows path separators
55 $webserver_root = str_replace("\\","/",$webserver_root);
57 // Auto collect the relative html path, i.e. what you would type into the web
58 // browser after the server address to get to OpenEMR.
59 $web_root = substr($webserver_root, strlen($_SERVER['DOCUMENT_ROOT']));
60 // Ensure web_root starts with a path separator
61 if (preg_match("/^[^\/]/",$web_root)) {
62 $web_root = "/".$web_root;
64 // The webserver_root and web_root are now automatically collected in
65 // real time per above code. If above is not working, can uncomment and
66 // set manually here:
67 // $webserver_root = "/var/www/openemr"
68 // $web_root = "/openemr"
71 // Collecting the utf8 disable flag from the sqlconf.php file in order
72 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
73 // then set to iso-8859-1.
74 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
75 if (!$disable_utf8_flag) {
76 ini_set('default_charset', 'utf-8');
77 $HTML_CHARSET = "UTF-8";
79 else {
80 ini_set('default_charset', 'iso-8859-1');
81 $HTML_CHARSET = "ISO-8859-1";
84 // Root directory, relative to the webserver root:
85 $GLOBALS['rootdir'] = "$web_root/interface";
86 $rootdir = $GLOBALS['rootdir'];
87 // Absolute path to the source code include and headers file directory (Full path):
88 $GLOBALS['srcdir'] = "$webserver_root/library";
89 // Absolute path to the location of documentroot directory for use with include statements:
90 $GLOBALS['fileroot'] = "$webserver_root";
91 // Absolute path to the location of interface directory for use with include statements:
92 $include_root = "$webserver_root/interface";
93 // Absolute path to the location of documentroot directory for use with include statements:
94 $GLOBALS['webroot'] = $web_root;
96 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
97 $GLOBALS['incdir'] = $include_root;
98 // Location of the login screen file
99 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
101 // Include the translation engine. This will also call sql.inc to
102 // open the openemr mysql connection.
103 include_once (dirname(__FILE__) . "/../library/translation.inc.php");
105 // Includes functions for date internationalization
106 include_once (dirname(__FILE__) . "/../library/date_functions.php");
108 // Defaults for specific applications.
109 $GLOBALS['athletic_team'] = false;
110 $GLOBALS['weight_loss_clinic'] = false;
111 $GLOBALS['ippf_specific'] = false;
112 $GLOBALS['cene_specific'] = false;
114 // Defaults for drugs and products.
115 $GLOBALS['inhouse_pharmacy'] = false;
116 $GLOBALS['sell_non_drug_products'] = 0;
118 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
119 if (!empty($glrow)) {
120 // Set global parameters from the database globals table.
121 // Some parameters require custom handling.
123 $GLOBALS['language_menu_show'] = array();
124 $glres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals " .
125 "ORDER BY gl_name, gl_index");
126 while ($glrow = sqlFetchArray($glres)) {
127 $gl_name = $glrow['gl_name'];
128 $gl_value = $glrow['gl_value'];
129 if ($gl_name == 'language_menu_other') {
130 $GLOBALS['language_menu_show'][] = $gl_value;
132 else if ($gl_name == 'css_header') {
133 $GLOBALS[$gl_name] = "$rootdir/themes/" . $gl_value;
135 else if ($gl_name == 'specific_application') {
136 if ($gl_value == '1') $GLOBALS['athletic_team'] = true;
137 else if ($gl_value == '2') $GLOBALS['ippf_specific'] = true;
138 else if ($gl_value == '3') $GLOBALS['weight_loss_clinic'] = true;
140 else if ($gl_name == 'inhouse_pharmacy') {
141 if ($gl_value) $GLOBALS['inhouse_pharmacy'] = true;
142 if ($gl_value == '2') $GLOBALS['sell_non_drug_products'] = 1;
143 else if ($gl_value == '3') $GLOBALS['sell_non_drug_products'] = 2;
145 else {
146 $GLOBALS[$gl_name] = $glrow['gl_value'];
149 // Language cleanup stuff.
150 $GLOBALS['language_menu_login'] = false;
151 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
152 $GLOBALS['language_menu_login'] = true;
155 // End of globals table processing.
157 else {
158 // Temporary stuff to handle the case where the globals table does not
159 // exist yet. This will happen in sql_upgrade.php on upgrading to the
160 // first release containing this table.
161 $GLOBALS['language_menu_login'] = true;
162 $GLOBALS['language_menu_showall'] = true;
163 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
164 $GLOBALS['language_default'] = "English (Standard)";
165 $GLOBALS['translate_layout'] = true;
166 $GLOBALS['translate_lists'] = true;
167 $GLOBALS['translate_gacl_groups'] = true;
168 $GLOBALS['translate_form_titles'] = true;
169 $GLOBALS['translate_document_categories'] = true;
170 $GLOBALS['translate_appt_categories'] = true;
171 $GLOBALS['concurrent_layout'] = 2;
172 $timeout = 7200;
173 $openemr_name = 'OpenEMR';
174 $css_header = "$rootdir/themes/style_sky_blue.css";
175 $GLOBALS['css_header'] = $css_header;
176 $GLOBALS['schedule_start'] = 8;
177 $GLOBALS['schedule_end'] = 17;
178 $GLOBALS['calendar_interval'] = 15;
179 $GLOBALS['phone_country_code'] = '1';
180 $GLOBALS['disable_non_default_groups'] = true;
181 $GLOBALS['ippf_specific'] = false;
185 // Lists and Layouts Control Section
188 // 'state_custom_addlist_widget'
189 // - If true, then will display a customized addlist widget for
190 // state list entries (will ask for title and abbreviation)
191 $GLOBALS['state_custom_addlist_widget'] = true;
192 $GLOBALS['state_list'] = "state";
193 $GLOBALS['country_list'] = "country";
195 // Option to set the top default window. By default, it is set
196 // to the calendar screen. The starting directory is
197 // interface/main/ , hence:
198 // The calendar screen is 'main_info.php' .
199 // The patient search/add screen is '../new/new.php' .
200 $GLOBALS['default_top_pane'] = 'main_info.php';
202 // Default category for find_patient screen
203 $GLOBALS['default_category'] = 5;
204 $GLOBALS['default_event_title'] = 'Office Visit';
206 // The session name appears in cookies stored in the browser. If you have
207 // multiple OpenEMR installations running on the same server, you should
208 // customize this name so they cannot interfere with each other.
210 // Also, if modify session_name, then need to place the identical name in
211 // the phpmyadmin file here: openemr/phpmyadmin/libraries/session.inc.php
212 // at line 71. This was required after embedded new phpmyadmin version on
213 // 05-12-2009 by Brady. Hopefully will figure out a more appropriate fix.
214 session_name("OpenEMR");
216 session_start();
218 // If >0 this will enforce a separate PHP session for each top-level
219 // browser window. You must log in separately for each. This is not
220 // thoroughly tested yet and some browsers might have trouble with it,
221 // so make it 0 if you must. Alternatively, you can set it to 2 to be
222 // notified when the session ID changes.
223 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
225 // Theme definition. All this stuff should be moved to CSS.
227 if ($GLOBALS['concurrent_layout']) {
228 $top_bg_line = ' bgcolor="#dddddd" ';
229 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
230 $bottom_bg_line = $top_bg_line;
231 $title_bg_line = ' bgcolor="#bbbbbb" ';
232 $nav_bg_line = ' bgcolor="#94d6e7" ';
233 } else {
234 $top_bg_line = ' bgcolor="#94d6e7" ';
235 $GLOBALS['style']['BGCOLOR2'] = "#94d6e7";
236 $bottom_bg_line = ' background="'.$rootdir.'/pic/aquabg.gif" ';
237 $title_bg_line = ' bgcolor="#aaffff" ';
238 $nav_bg_line = ' bgcolor="#94d6e7" ';
240 $login_filler_line = ' bgcolor="#f7f0d5" ';
241 $login_body_line = ' background="'.$rootdir.'/pic/aquabg.gif" ';
242 $logocode="<img src='$rootdir/pic/logo_sky.gif'>";
243 $linepic = "$rootdir/pic/repeat_vline9.gif";
244 $table_bg = ' bgcolor="#cccccc" ';
245 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
246 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
247 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
248 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
249 // The height in pixels of the Logo bar at the top of the login page:
250 $GLOBALS['logoBarHeight'] = 110;
251 // The height in pixels of the Navigation bar:
252 $GLOBALS['navBarHeight'] = 22;
253 // The height in pixels of the Title bar:
254 $GLOBALS['titleBarHeight'] = 20;
256 // The assistant word, MORE printed next to titles that can be clicked:
257 // Note this label gets translated here via the xl function
258 // -if you don't want it translated, then strip the xl function away
259 $tmore = xl('(More)');
260 // The assistant word, BACK printed next to titles that return to previous screens:
261 // Note this label gets translated here via the xl function
262 // -if you don't want it translated, then strip the xl function away
263 $tback = xl('(Back)');
265 // This is the idle logout function:
266 // if a page has not been refreshed within this many seconds, the interface
267 // will return to the login page
268 if (!empty($special_timeout)) {
269 $timeout = intval($special_timeout);
272 //Version tags
274 $v_major = '4';
275 $v_minor = '0';
276 $v_patch = '0';
277 $tag = '-dev'; // minor revision number, should be empty for production releases
279 $openemr_version = "$v_major.$v_minor.$v_patch".$tag; // Version tag used by program
281 $srcdir = $GLOBALS['srcdir'];
282 $login_screen = $GLOBALS['login_screen'];
283 $GLOBALS['css_header'] = $css_header;
284 $GLOBALS['backpic'] = $backpic;
286 // 1 = send email message to given id for Emergency Login user activation,
287 // else 0.
288 $GLOBALS['Emergency_Login_email'] = $GLOBALS['Emergency_Login_email_id'] ? 1 : 0;
290 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
291 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
292 //functions, tables for de-identification(Mysql root user and password is required for successful
293 //execution of the de-identification upgrade script)
294 $GLOBALS['include_de_identification']=0;
295 // Include the authentication module code here, but the rule is
296 // if the file has the word "login" in the source code file name,
297 // don't include the authentication module - we do this to avoid
298 // include loops.
300 if (!$ignoreAuth) {
301 include_once("$srcdir/auth.inc");
304 // If you do not want your accounting system to have a customer added to it
305 // for each insurance company, then set this to true. SQL-Ledger currently
306 // (2005-03-21) does nothing useful with insurance companies as customers.
307 $GLOBALS['insurance_companies_are_not_customers'] = true;
309 // This is the background color to apply to form fields that are searchable.
310 // Currently it is applicable only to the "Search or Add Patient" form.
311 $GLOBALS['layout_search_color'] = '#ffff55';
313 //EMAIL SETTINGS
314 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
316 // The following credentials are provided by OpenEMR Support LLC for testing.
317 // When you sign up with their Lab Exchange service, they will provide you with your own credentials.
319 /* use this for testing
320 $LAB_EXCHANGE_SITEID = "3";
321 $LAB_EXCHANGE_TOKEN = "12345";
322 $LAB_EXCHANGE_ENDPOINT = "https://openemrsupport.com:29443/len/api";
325 $LAB_EXCHANGE_SITEID = "";
326 $LAB_EXCHANGE_TOKEN = "";
327 $LAB_EXCHANGE_ENDPOINT = "";
329 // If you want Hylafax support then uncomment and customize the following
330 // statements, and also customize custom/faxcover.txt:
332 // $GLOBALS['hylafax_server'] = 'localhost';
333 // $GLOBALS['hylafax_basedir'] = '/var/spool/fax';
334 // $GLOBALS['hylafax_enscript'] = 'enscript -M Letter -B -e^ --margins=36:36:36:36';
336 // For scanner support, uncomment and customize the following. This is
337 // the directory in which scanned-in documents may be found, and may for
338 // example be a smbfs-mounted share from the PC supporting the scanner:
340 // $GLOBALS['scanner_output_directory'] = '/mnt/scan_docs';
342 // Customize these if you are using SQL-Ledger with OpenEMR, or if you are
343 // going to run sl_convert.php to convert from SQL-Ledger.
345 $sl_cash_acc = '1060'; // sql-ledger account number for checking account
346 $sl_ar_acc = '1200'; // sql-ledger account number for accounts receivable
347 $sl_income_acc = '4320'; // sql-ledger account number for medical services income
348 $sl_services_id = 'MS'; // sql-ledger parts table id for medical services
349 $sl_dbname = 'sql-ledger'; // sql-ledger database name
350 $sl_dbuser = 'sql-ledger'; // sql-ledger database login name
351 $sl_dbpass = 'secret'; // sql-ledger database login password
353 ///////////////////////// AUDIT LOGGING CONFIG ////////////////
354 //$GLOBALS["enable_auditlog"]=0 is to off the logging feature in openemr
355 //$GLOBALS["enable_auditlog"]=1 is to on the logging feature in openemr
356 //patient-record:- set 1 (0 to off) to log the patient related activites like creation of new patient, encounters, history//etc.
357 //scheduling:- set 1 (0 to off) to log the patient related scheduling like Appointments.
358 //query:- set 1 (0 to off) to log all SQL SELECT queries.
359 //order:- set 1 (0 to off) to log an orders like medical service or medical item (like a prescription).
360 //security-administration:- set 1 to (0 to off) to log events such as creating/updating users/facility etc.
361 //backup:- set 1 (0 to off) to log backup related activites.
363 //Turning off Auditing. It is currently broken due to the conflicts with LAST_INSERT_ID
364 $GLOBALS["enable_auditlog"]=1;
365 $GLOBALS["audit_events"]=array("patient-record"=>1,
366 "scheduling"=>1,
367 "query"=>0,
368 "order"=>1,
369 "security-administration"=>1,
370 "backup"=>1,
373 // Configure the settings below to enable Audit Trail and Node Authentication (ATNA).
374 // See RFC 3881, RFC 5424, RFC 5425 for details.
375 // atna_audit_host = The hostname of the audit repository machine
376 // atna_audit_port = Listening port of the RFC 5425 TLS syslog server
377 // atna_audit_localcert - Certificate to send to RFC 5425 TLS syslog server
378 // atna_audit_cacert - CA Certificate for verifying the RFC 5425 TLS syslog server
379 $GLOBALS['atna_audit_host'] = '';
380 $GLOBALS['atna_audit_port'] = 6514;
381 $GLOBALS['atna_audit_localcert'] = '';
382 $GLOBALS['atna_audit_cacert'] = '';
383 //////////////////////////////////////////////////////////////////
385 // Don't change anything below this line. ////////////////////////////
387 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
389 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
390 $_SESSION['pid'] = $_GET['pid'];
392 elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
393 $_SESSION['pid'] = $_POST['pid'];
395 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
396 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
397 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
399 // global interface function to format text length using ellipses
400 function strterm($string,$length) {
401 if (strlen($string) >= ($length-3)) {
402 return substr($string,0,$length-3) . "...";
403 } else {
404 return $string;
408 // Override temporary_files_dir if PHP >= 5.2.1.
409 if (version_compare(phpversion(), "5.2.1", ">=")) {
410 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(),'/');
413 // turn off PHP compatibility warnings
414 ini_set("session.bug_compat_warn","off");
416 //////////////////////////////////////////////////////////////////