Removed the php.ini memory limit override
[openemr.git] / interface / globals.php
blob3f9d98f9a5ed1e5a6d8c9416a23213daf35d4556
1 <?php
3 // Is this windows or non-windows? Create a boolean definition.
4 if (!defined('IS_WINDOWS'))
5 define('IS_WINDOWS', (stripos(PHP_OS,'WIN') === 0));
7 // Some important php.ini overrides. Defaults for these values are often
8 // too small. You might choose to adjust them further.
9 //
10 ini_set('session.gc_maxlifetime', '14400');
12 /* If the includer didn't specify, assume they want us to "fake" register_globals. */
13 if (!isset($fake_register_globals)) {
14 $fake_register_globals = TRUE;
17 /* Pages with "myadmin" in the URL don't need register_globals. */
18 $fake_register_globals =
19 $fake_register_globals && (strpos($_SERVER['REQUEST_URI'],"myadmin") === FALSE);
21 // Emulates register_globals = On. Moved to here from the bottom of this file
22 // to address security issues. Need to change everything requiring this!
23 if ($fake_register_globals) {
24 extract($_GET);
25 extract($_POST);
28 // This is for sanitization of all escapes.
29 // (ie. reversing magic quotes if it's set)
30 if (isset($sanitize_all_escapes) && $sanitize_all_escapes) {
31 if (get_magic_quotes_gpc()) {
32 function undoMagicQuotes($array, $topLevel=true) {
33 $newArray = array();
34 foreach($array as $key => $value) {
35 if (!$topLevel) {
36 $key = stripslashes($key);
38 if (is_array($value)) {
39 $newArray[$key] = undoMagicQuotes($value, false);
41 else {
42 $newArray[$key] = stripslashes($value);
45 return $newArray;
47 $_GET = undoMagicQuotes($_GET);
48 $_POST = undoMagicQuotes($_POST);
49 $_COOKIE = undoMagicQuotes($_COOKIE);
50 $_REQUEST = undoMagicQuotes($_REQUEST);
55 // The webserver_root and web_root are now automatically collected.
56 // If not working, can set manually below.
57 // Auto collect the full absolute directory path for openemr.
58 $webserver_root = dirname(dirname(__FILE__));
59 if (IS_WINDOWS) {
60 //convert windows path separators
61 $webserver_root = str_replace("\\","/",$webserver_root);
63 // Auto collect the relative html path, i.e. what you would type into the web
64 // browser after the server address to get to OpenEMR.
65 $web_root = substr($webserver_root, strlen($_SERVER['DOCUMENT_ROOT']));
66 // Ensure web_root starts with a path separator
67 if (preg_match("/^[^\/]/",$web_root)) {
68 $web_root = "/".$web_root;
70 // The webserver_root and web_root are now automatically collected in
71 // real time per above code. If above is not working, can uncomment and
72 // set manually here:
73 // $webserver_root = "/var/www/openemr";
74 // $web_root = "/openemr";
77 // This is the directory that contains site-specific data. Change this
78 // only if you have some reason to.
79 $GLOBALS['OE_SITES_BASE'] = "$webserver_root/sites";
81 // The session name names a cookie stored in the browser.
82 // If you modify session_name, then need to place the identical name in
83 // the phpmyadmin file here: openemr/phpmyadmin/libraries/session.inc.php
84 // at line 71. This was required after embedded new phpmyadmin version on
85 // 05-12-2009 by Brady. Hopefully will figure out a more appropriate fix.
86 // Now that restore_session() is implemented in javaScript, session IDs are
87 // effectively saved in the top level browser window and there is no longer
88 // any need to change the session name for different OpenEMR instances.
89 session_name("OpenEMR");
91 session_start();
93 // Set the site ID if required. This must be done before any database
94 // access is attempted.
95 if (empty($_SESSION['site_id']) || !empty($_GET['site'])) {
96 if (!empty($_GET['site'])) {
97 $tmp = $_GET['site'];
99 else {
100 if (!$ignoreAuth) die("Site ID is missing from session data!");
101 $tmp = $_SERVER['HTTP_HOST'];
102 if (!is_dir($GLOBALS['OE_SITES_BASE'] . "/$tmp")) $tmp = "default";
104 if (empty($tmp) || preg_match('/[^A-Za-z0-9\\-.]/', $tmp))
105 die("Site ID '". htmlspecialchars($tmp,ENT_NOQUOTES) . "' contains invalid characters.");
106 if (!isset($_SESSION['site_id']) || $_SESSION['site_id'] != $tmp) {
107 $_SESSION['site_id'] = $tmp;
108 //error_log("Session site ID has been set to '$tmp'"); // debugging
112 // Set the site-specific directory path.
113 $GLOBALS['OE_SITE_DIR'] = $GLOBALS['OE_SITES_BASE'] . "/" . $_SESSION['site_id'];
115 require_once($GLOBALS['OE_SITE_DIR'] . "/config.php");
117 // Collecting the utf8 disable flag from the sqlconf.php file in order
118 // to set the correct html encoding. utf8 vs iso-8859-1. If flag is set
119 // then set to iso-8859-1.
120 require_once(dirname(__FILE__) . "/../library/sqlconf.php");
121 if (!$disable_utf8_flag) {
122 ini_set('default_charset', 'utf-8');
123 $HTML_CHARSET = "UTF-8";
125 else {
126 ini_set('default_charset', 'iso-8859-1');
127 $HTML_CHARSET = "ISO-8859-1";
130 // Root directory, relative to the webserver root:
131 $GLOBALS['rootdir'] = "$web_root/interface";
132 $rootdir = $GLOBALS['rootdir'];
133 // Absolute path to the source code include and headers file directory (Full path):
134 $GLOBALS['srcdir'] = "$webserver_root/library";
135 // Absolute path to the location of documentroot directory for use with include statements:
136 $GLOBALS['fileroot'] = "$webserver_root";
137 // Absolute path to the location of interface directory for use with include statements:
138 $include_root = "$webserver_root/interface";
139 // Absolute path to the location of documentroot directory for use with include statements:
140 $GLOBALS['webroot'] = $web_root;
142 $GLOBALS['template_dir'] = $GLOBALS['fileroot'] . "/templates/";
143 $GLOBALS['incdir'] = $include_root;
144 // Location of the login screen file
145 $GLOBALS['login_screen'] = $GLOBALS['rootdir'] . "/login_screen.php";
147 // Variable set for Eligibility Verification [EDI-271] path
148 $GLOBALS['edi_271_file_path'] = $GLOBALS['OE_SITE_DIR'] . "/edi/";
150 // Include the translation engine. This will also call sql.inc to
151 // open the openemr mysql connection.
152 include_once (dirname(__FILE__) . "/../library/translation.inc.php");
154 // Include convenience functions with shorter names than "htmlspecialchars" (for security)
155 require_once (dirname(__FILE__) . "/../library/htmlspecialchars.inc.php");
157 // Include sanitization/checking functions (for security)
158 require_once (dirname(__FILE__) . "/../library/formdata.inc.php");
160 // Include sanitization/checking function (for security)
161 require_once (dirname(__FILE__) . "/../library/sanitize.inc.php");
163 // Includes functions for date internationalization
164 include_once (dirname(__FILE__) . "/../library/date_functions.php");
166 // Defaults for specific applications.
167 $GLOBALS['athletic_team'] = false;
168 $GLOBALS['weight_loss_clinic'] = false;
169 $GLOBALS['ippf_specific'] = false;
170 $GLOBALS['cene_specific'] = false;
172 // Defaults for drugs and products.
173 $GLOBALS['inhouse_pharmacy'] = false;
174 $GLOBALS['sell_non_drug_products'] = 0;
176 $glrow = sqlQuery("SHOW TABLES LIKE 'globals'");
177 if (!empty($glrow)) {
178 // Collect user specific settings from user_settings table.
180 $gl_user = array();
181 if (!empty($_SESSION['authUserID'])) {
182 $glres_user = sqlStatement("SELECT `setting_label`, `setting_value` " .
183 "FROM `user_settings` " .
184 "WHERE `setting_user` = ? " .
185 "AND `setting_label` LIKE 'global:%'", array($_SESSION['authUserID']) );
186 for($iter=0; $row=sqlFetchArray($glres_user); $iter++) {
187 //remove global_ prefix from label
188 $row['setting_label'] = substr($row['setting_label'],7);
189 $gl_user[$iter]=$row;
192 // Set global parameters from the database globals table.
193 // Some parameters require custom handling.
195 $GLOBALS['language_menu_show'] = array();
196 $glres = sqlStatement("SELECT gl_name, gl_index, gl_value FROM globals " .
197 "ORDER BY gl_name, gl_index");
198 while ($glrow = sqlFetchArray($glres)) {
199 $gl_name = $glrow['gl_name'];
200 $gl_value = $glrow['gl_value'];
201 // Adjust for user specific settings
202 if (!empty($gl_user)) {
203 foreach ($gl_user as $setting) {
204 if ($gl_name == $setting['setting_label']) {
205 $gl_value = $setting['setting_value'];
209 if ($gl_name == 'language_menu_other') {
210 $GLOBALS['language_menu_show'][] = $gl_value;
212 else if ($gl_name == 'css_header') {
213 $GLOBALS[$gl_name] = "$rootdir/themes/" . $gl_value;
215 else if ($gl_name == 'specific_application') {
216 if ($gl_value == '1') $GLOBALS['athletic_team'] = true;
217 else if ($gl_value == '2') $GLOBALS['ippf_specific'] = true;
218 else if ($gl_value == '3') $GLOBALS['weight_loss_clinic'] = true;
220 else if ($gl_name == 'inhouse_pharmacy') {
221 if ($gl_value) $GLOBALS['inhouse_pharmacy'] = true;
222 if ($gl_value == '2') $GLOBALS['sell_non_drug_products'] = 1;
223 else if ($gl_value == '3') $GLOBALS['sell_non_drug_products'] = 2;
225 else {
226 $GLOBALS[$gl_name] = $gl_value;
229 // Language cleanup stuff.
230 $GLOBALS['language_menu_login'] = false;
231 if ((count($GLOBALS['language_menu_show']) >= 1) || $GLOBALS['language_menu_showall']) {
232 $GLOBALS['language_menu_login'] = true;
235 // End of globals table processing.
237 else {
238 // Temporary stuff to handle the case where the globals table does not
239 // exist yet. This will happen in sql_upgrade.php on upgrading to the
240 // first release containing this table.
241 $GLOBALS['language_menu_login'] = true;
242 $GLOBALS['language_menu_showall'] = true;
243 $GLOBALS['language_menu_show'] = array('English (Standard)','Swedish');
244 $GLOBALS['language_default'] = "English (Standard)";
245 $GLOBALS['translate_layout'] = true;
246 $GLOBALS['translate_lists'] = true;
247 $GLOBALS['translate_gacl_groups'] = true;
248 $GLOBALS['translate_form_titles'] = true;
249 $GLOBALS['translate_document_categories'] = true;
250 $GLOBALS['translate_appt_categories'] = true;
251 $GLOBALS['concurrent_layout'] = 2;
252 $timeout = 7200;
253 $openemr_name = 'OpenEMR';
254 $css_header = "$rootdir/themes/style_default.css";
255 $GLOBALS['css_header'] = $css_header;
256 $GLOBALS['schedule_start'] = 8;
257 $GLOBALS['schedule_end'] = 17;
258 $GLOBALS['calendar_interval'] = 15;
259 $GLOBALS['phone_country_code'] = '1';
260 $GLOBALS['disable_non_default_groups'] = true;
261 $GLOBALS['ippf_specific'] = false;
264 // If >0 this will enforce a separate PHP session for each top-level
265 // browser window. You must log in separately for each. This is not
266 // thoroughly tested yet and some browsers might have trouble with it,
267 // so make it 0 if you must. Alternatively, you can set it to 2 to be
268 // notified when the session ID changes.
269 $GLOBALS['restore_sessions'] = 1; // 0=no, 1=yes, 2=yes+debug
271 // Theme definition. All this stuff should be moved to CSS.
273 if ($GLOBALS['concurrent_layout']) {
274 $top_bg_line = ' bgcolor="#dddddd" ';
275 $GLOBALS['style']['BGCOLOR2'] = "#dddddd";
276 $bottom_bg_line = $top_bg_line;
277 $title_bg_line = ' bgcolor="#bbbbbb" ';
278 $nav_bg_line = ' bgcolor="#94d6e7" ';
279 } else {
280 $top_bg_line = ' bgcolor="#94d6e7" ';
281 $GLOBALS['style']['BGCOLOR2'] = "#94d6e7";
282 $bottom_bg_line = ' background="'.$rootdir.'/pic/aquabg.gif" ';
283 $title_bg_line = ' bgcolor="#aaffff" ';
284 $nav_bg_line = ' bgcolor="#94d6e7" ';
286 $login_filler_line = ' bgcolor="#f7f0d5" ';
287 $logocode = "<img src='$web_root/sites/" . $_SESSION['site_id'] . "/images/login_logo.gif'>";
288 $linepic = "$rootdir/pic/repeat_vline9.gif";
289 $table_bg = ' bgcolor="#cccccc" ';
290 $GLOBALS['style']['BGCOLOR1'] = "#cccccc";
291 $GLOBALS['style']['TEXTCOLOR11'] = "#222222";
292 $GLOBALS['style']['HIGHLIGHTCOLOR'] = "#dddddd";
293 $GLOBALS['style']['BOTTOM_BG_LINE'] = $bottom_bg_line;
294 // The height in pixels of the Logo bar at the top of the login page:
295 $GLOBALS['logoBarHeight'] = 110;
296 // The height in pixels of the Navigation bar:
297 $GLOBALS['navBarHeight'] = 22;
298 // The height in pixels of the Title bar:
299 $GLOBALS['titleBarHeight'] = 40;
301 // The assistant word, MORE printed next to titles that can be clicked:
302 // Note this label gets translated here via the xl function
303 // -if you don't want it translated, then strip the xl function away
304 $tmore = xl('(More)');
305 // The assistant word, BACK printed next to titles that return to previous screens:
306 // Note this label gets translated here via the xl function
307 // -if you don't want it translated, then strip the xl function away
308 $tback = xl('(Back)');
310 // This is the idle logout function:
311 // if a page has not been refreshed within this many seconds, the interface
312 // will return to the login page
313 if (!empty($special_timeout)) {
314 $timeout = intval($special_timeout);
317 //Version tag
318 require_once(dirname(__FILE__) . "/../version.php");
319 $patch_appending = "";
320 if ( ($v_realpatch != '0') && (!(empty($v_realpatch))) ) {
321 $patch_appending = " (".$v_realpatch.")";
323 $openemr_version = "$v_major.$v_minor.$v_patch".$v_tag.$patch_appending;
325 $srcdir = $GLOBALS['srcdir'];
326 $login_screen = $GLOBALS['login_screen'];
327 $GLOBALS['css_header'] = $css_header;
328 $GLOBALS['backpic'] = $backpic;
330 // 1 = send email message to given id for Emergency Login user activation,
331 // else 0.
332 $GLOBALS['Emergency_Login_email'] = $GLOBALS['Emergency_Login_email_id'] ? 1 : 0;
334 //set include_de_identification to enable De-identification (currently de-identification works fine only with linux machines)
335 //Run de_identification_upgrade.php script to upgrade OpenEMR database to include procedures,
336 //functions, tables for de-identification(Mysql root user and password is required for successful
337 //execution of the de-identification upgrade script)
338 $GLOBALS['include_de_identification']=0;
339 // Include the authentication module code here, but the rule is
340 // if the file has the word "login" in the source code file name,
341 // don't include the authentication module - we do this to avoid
342 // include loops.
344 if (!isset($ignoreAuth) || !$ignoreAuth) {
345 include_once("$srcdir/auth.inc");
348 // If you do not want your accounting system to have a customer added to it
349 // for each insurance company, then set this to true. SQL-Ledger currently
350 // (2005-03-21) does nothing useful with insurance companies as customers.
351 $GLOBALS['insurance_companies_are_not_customers'] = true;
353 // This is the background color to apply to form fields that are searchable.
354 // Currently it is applicable only to the "Search or Add Patient" form.
355 $GLOBALS['layout_search_color'] = '#ffff55';
357 //EMAIL SETTINGS
358 $SMTP_Auth = !empty($GLOBALS['SMTP_USER']);
360 // Customize these if you are using SQL-Ledger with OpenEMR, or if you are
361 // going to run sl_convert.php to convert from SQL-Ledger.
363 $sl_cash_acc = '1060'; // sql-ledger account number for checking account
364 $sl_ar_acc = '1200'; // sql-ledger account number for accounts receivable
365 $sl_income_acc = '4320'; // sql-ledger account number for medical services income
366 $sl_services_id = 'MS'; // sql-ledger parts table id for medical services
367 $sl_dbname = 'sql-ledger'; // sql-ledger database name
368 $sl_dbuser = 'sql-ledger'; // sql-ledger database login name
369 $sl_dbpass = 'secret'; // sql-ledger database login password
370 //////////////////////////////////////////////////////////////////
372 // Don't change anything below this line. ////////////////////////////
374 $encounter = empty($_SESSION['encounter']) ? 0 : $_SESSION['encounter'];
376 if (!empty($_GET['pid']) && empty($_SESSION['pid'])) {
377 $_SESSION['pid'] = $_GET['pid'];
379 elseif (!empty($_POST['pid']) && empty($_SESSION['pid'])) {
380 $_SESSION['pid'] = $_POST['pid'];
382 $pid = empty($_SESSION['pid']) ? 0 : $_SESSION['pid'];
383 $userauthorized = empty($_SESSION['userauthorized']) ? 0 : $_SESSION['userauthorized'];
384 $groupname = empty($_SESSION['authProvider']) ? 0 : $_SESSION['authProvider'];
386 // global interface function to format text length using ellipses
387 function strterm($string,$length) {
388 if (strlen($string) >= ($length-3)) {
389 return substr($string,0,$length-3) . "...";
390 } else {
391 return $string;
395 // Override temporary_files_dir if PHP >= 5.2.1.
396 if (version_compare(phpversion(), "5.2.1", ">=")) {
397 $GLOBALS['temporary_files_dir'] = rtrim(sys_get_temp_dir(),'/');
400 // turn off PHP compatibility warnings
401 ini_set("session.bug_compat_warn","off");
403 //////////////////////////////////////////////////////////////////