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