forked from israelpascal/care2x-tz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php~
executable file
·415 lines (343 loc) · 12.7 KB
/
index.php~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
<?php
/*
define (__TRACE_ENABLE__, true);
define (__DEBUG_ENABLE__, true);
define (__DEBUG_HOST__, "localhost");
define (__DEBUG_PORT__, "9000");
*/
/*
CARE 2X Integrated Information System for Hospitals and Health Care Organizations and Services
Care 2002, Care2x, Copyright (C) 2002,2003,2004,2005 Elpidio Latorilla
Deployment 2.1 - 2004-10-02
This script(s) is(are) free software; you can redistribute it and/or
modify it under the terms of the GNU General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This software is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public
License along with this script; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copy of GNU General Public License at: http://www.gnu.org/
Source code home page: http://www.care2x.org
Contact author at: [email protected]
This notice also applies to other scripts which are integral to the functioning of CARE 2X within this directory and its top level directory
A copy of this notice is also available as file named copy_notice.txt under the top level directory.
*/
//error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
define('FROM_ROOT',1);
if(!isset($mask)) $mask=false;
if(!isset($cookie)) $cookie=false;
if(!isset($_chg_lang_)) $_chg_lang_=false;
if(!isset($boot)) $boot=false;
if(!isset($sid)) $sid='';
require('./roots.php');
require('./include/inc_environment_global.php');
//$db->debug=1;
# Register global session variables
$_SESSION['sess_user_name']='';
$_SESSION['sess_user_origin']='';
$_SESSION['sess_file_forward']='';
$_SESSION['sess_file_return']='';
$_SESSION['sess_file_break']='';
$_SESSION['sess_path_referer']='';
$_SESSION['sess_dept_nr']='';
$_SESSION['sess_title']='';
$_SESSION['sess_lang']='';
$_SESSION['sess_user_id']='';
$_SESSION['sess_cur_page']='';
$_SESSION['sess_searchkey']='';
$_SESSION['sess_tos']='';
if(!isset($_SESSION['sess_user_name'])) $_SESSION['sess_user_name'];
if(!isset($_SESSION['sess_user_origin'])) $_SESSION['sess_user_origin'];
if(!isset($_SESSION['sess_file_forward'])) $_SESSION['sess_file_forward'];
if(!isset($_SESSION['sess_file_return'])) $_SESSION['sess_file_return'];
if(!isset($_SESSION['sess_file_break'])) $_SESSION['sess_file_break'];
if(!isset($_SESSION['sess_path_referer'])) $_SESSION['sess_path_referer'];
if(!isset($_SESSION['sess_dept_nr'])) $_SESSION['sess_dept_nr'];
if(!isset($_SESSION['sess_title'])) $_SESSION['sess_title'];
if(!isset($_SESSION['sess_lang'])) $_SESSION['sess_lang']
if(!isset($_SESSION['sess_user_id'])) $_SESSION['sess_user_id'];
if(!isset($_SESSION['sess_cur_page'])) $_SESSION['sess_cur_page'];
if(!isset($_SESSION['sess_searchkey'])) $_SESSION['sess_searchkey'];
if(!isset($_SESSION['sess_tos'])) $_SESSION['sess_tos']; # the session time out start time
$bname='';
$bversion='';
$user_id='';
$ip='';
$cfgid='';
$config_exists=false;
$GLOBALCONFIG=array();
$USERCONFIG=array();
/****************************************************************************
phpSniff: HTTP_USER_AGENT Client Sniffer for PHP
Copyright (C) 2001 Roger Raymond ~ [email protected]
* Check environment : Browser, OS
* @param string $bn name of browser
* @param string $bv version of browser
* @param string $f CFG filename
* @param string $i IP adress
* @param string $uid new guid (session var)
* @return all parameter using &
* @access public
*
* 02.02.2003 Thomas Wiedmann
****************************************************************************
*/
require_once('./classes/phpSniff/phpSniff.class.php'); # Sniffer for PHP
function configNew($bn,$bv,$f,$i,$uid)
{
// global $HTTP_USER_AGENT;
// global $REMOTE_ADDR;
# We disable the error reporting, because Konqueror 3.0.3 causes a runtime error output that stops the program.
# could be a bug in phpsniff .. hmmm?
$old_err_rep= error_reporting(E_COMPILE_ERROR|E_ERROR|E_CORE_ERROR);
# Function rewritten by Thomas Wiedmann to use phpSniff class
# initialize some vars
if(!isset($UA)) $UA = '';
if(!isset($cc)) $cc = '';
if(!isset($dl)) $dl = '';
if(!isset($am)) $am = '';
//$timer = new phpTimer();
//$timer->start('main');
//$timer->start('client1');
$sniffer_settings = array('check_cookies'=>$cc,'default_language'=>$dl,'allow_masquerading'=>$am);
$client = new phpSniff($UA,$sniffer_settings);
# get phpSniff result
$i=$client->get_property('ip');
$bv=$client->get_property('version');
$bn=$client->get_property('browser');
# translate some browsernames for "Care2x"
if ($bn == 'moz') { $bn='mozilla';}
else if ($bn == 'op') { $bn='opera';}
else if ($bn == 'ns') { $bn='netscape';}
else if ($bn == 'ie') { $bn='msie';}
$uid=uniqid('');
$f='CFG'.$uid.microtime().'.cfg';
# Return previous error reporting
error_reporting($old_err_rep);
}
/**
* Create simple session id (sid), save a encrpyted sid to a cookie with a dynamic name
* consisting of concatenating "ck_sid" and the sid itself.
* For more information about the encryption class, see the proper docs of the pear's "hcemd5.php" class.
*/
//$sid=uniqid('');
$sid=session_id();
$ck_sid_buffer='ck_sid'.$sid;
include('include/inc_init_crypt.php'); // initialize crypt
$ciphersid=$enc_hcemd5->encodeMimeSelfRand($sid);
setcookie($ck_sid_buffer,$ciphersid);
$_COOKIE[$ck_sid_buffer]=$ciphersid;
#
# Simple counter, counts all hits including revisits
# Uncomment the following line if you like to count the hits, then make sure
# that the path /counter/hits/ and the file /counter/hitcount.txt are system writeable
#
// include('./counter/count.php');
include('include/inc_init_main.php');
if( $dbname == '')
{
header('Location:installer/install.php');
}
if((isset($boot)&&$boot)||!isset($_COOKIE['ck_config'])||empty($_COOKIE['ck_config'])) {
configNew($bname,$bversion,$user_id,$ip,$cfgid);
} else {
$user_id=$_COOKIE['ck_config'];
}
#
# Load user config API. Get the user config data from db
#
require_once('include/care_api_classes/class_userconfig.php');
$cfg_obj=new UserConfig;
if($cfg_obj->exists($user_id)) {
$cfg_obj->getConfig($user_id);
$USERCONFIG=$cfg_obj->buffer;
$config_exists=true; // Flag that user config is existing
}else{
$cfg_obj->_getDefault();
$USERCONFIG=$cfg_obj->buffer;
}
# Load global configurations API
require_once('include/care_api_classes/class_globalconfig.php');
$glob_cfg=new GlobalConfig($GLOBALCONFIG);
# Get the global config for language usage
$glob_cfg->getConfig('language_%');
# Get the global config for frames
$glob_cfg->getConfig('gui_frame_left_nav_width');
# Get the global config for lev nav border
$glob_cfg->getConfig('gui_frame_left_nav_border');
$savelang=0;
/*echo $GLOBALCONFIG['language_non_single'];
while (list($x,$v)=each($GLOBALCONFIG)) echo $x.'==>'.$v.'<br>';
*/
# Start checking language properties
if(!$GLOBALCONFIG['language_single']) {
# We get the language code
if($_chg_lang_&&!empty($lang)) {
$savelang=1;
}else{
echo $lang=$USERCONFIG['lang'];
if($USERCONFIG['lang']) $lang=$USERCONFIG['lang'];
else include('chklang.php');
}
}else{
# If single language is configured, we get the user configured lang
if(!empty($USERCONFIG['lang']) && file_exists('language/'.$USERCONFIG['lang'].'/lang_'.$USERCONFIG['lang'].'_startframe.php')) {
$lang=$USERCONFIG['lang'];
} else {
# If user config lang is not available, we get the global system lang configuration
if(!empty($GLOBALCONFIG['language_default']) && file_exists('language/'.$GLOBALCONFIG['language_default'].'/lang_'.$GLOBALCONFIG['language_default'].'_startframe.php')) {
$lang=$GLOBALCONFIG['language_default'];
} else {
$lang=LANG_DEFAULT; # Comes from inc_environment_global.php, the last chance, usually set to "en"
}
}
}
#
# After having a language code check if the critical scripts exist and set warning
#
$createwarn=file_exists('create_admin.php');
$initwarn=file_exists('./install/initialize.php');
$md5warn=file_exists('./install/encode_pw_md5.php');
$installwarn=file_exists('./install/install.php');
if($createwarn||$installwarn||$md5warn){
#
# Load necessary language tables
#
$lang_tables[]='create_admin.php';
include_once('./include/inc_load_lang_tables.php');
include_once('include/inc_charset_fx.php');
if($createwarn){
include('./include/inc_create_admin_warning.php');
}
if($initwarn){
include('./include/inc_init_warning.php');
}
if($md5warn){
include('./include/inc_md5_warning.php');
}
if($installwarn){
include('./include/inc_install_warning.php');
}
#
# exit to avoid running the program
#
exit;
}
#
# Prepare language file path
#
$lang_file='language/'.$lang.'/lang_'.$lang.'_startframe.php';
#
# We check if language table exists, if not, english is used
#
if(file_exists($lang_file)) {
include($lang_file);
} else {
include('language/en/lang_en_startframe.php'); # en = english is the default language table
$lang='en';
}
#
# The language detection is finished, we save it to session
#
$_SESSION['sess_lang']=$lang;
/*$ck_lang_buffer='ck_lang'.$sid;
setcookie($ck_lang_buffer,$lang);*/
/*$_COOKIE[$ck_lang_buffer]=$lang;*/
//echo $mask;
if((isset($mask)&&$mask)||!$config_exists||$savelang) {
if(!$config_exists) {
//$cfg_obj->getConfig('default');
//$USERCONFIG=&$cfg_obj->buffer;
configNew($bname,$bversion,$user_id,$ip,$cfgid);
$USERCONFIG['bname']=$bname;
$USERCONFIG['bversion']=$bversion;
$USERCONFIG['cid']=$cfgid;
}
// *****************************
//save browser info to user config array
// *****************************
if(empty($ip)) $USERCONFIG['ip']=$REMOTE_ADDR;
$USERCONFIG['mask']=$mask;
$USERCONFIG['lang']=$lang;
if(((($bname=='msie') ||($bname=='opera')) &&($bversion>4)) ||(($bname=='netscape')&&($bversion>3.5)) ||($bname=='mozilla')) {
$USERCONFIG['dhtml']=1;
}
// *****************************
// Save config to db
// *****************************
$mask=$USERCONFIG['mask']; # save mask before serializing
$cfg_obj->saveConfig($user_id,$USERCONFIG);
setcookie('ck_config',$user_id,time()+(3600*24*365)); # expires after 1 year
}
#
# save user_id to session
#
$_SESSION['sess_user_id']=$user_id;
if(empty($_SESSION['sess_user_name'])) $_SESSION['sess_user_name']='default';
#
# set the initial session timeout start value
#
$_SESSION['sess_tos']=date('His');
#
# Load character set fx
#
include_once('include/inc_charset_fx.php');
#
# Load image fx
#
require_once('include/inc_img_fx.php');
#
# Start smarty templating
#
# Workaround for user config array to work inside the smarty class
#
$cfg = $USERCONFIG;
//while(list($x,$v)=each($cfg)) echo "$x => $v<br>";
require_once($root_path.'gui/smarty_template/smarty_care.class.php');
$smarty = new smarty_care('common');
#
# Window bar title
#
$smarty->assign('sWindowTitle',$LDMainTitle);
#
# Assign the contents frame source
#
$smarty->assign('sContentsFrameSource',"src = \"blank.php?lang=$lang&sid=$sid\"");
#
# Load the gui template
#
//require('gui/html_template/default/tp_index.php');
#
# If the floating menu window is selected
#
if($mask == 2){
if($lang=='ar'||$lang=='fa') $smarty->assign('sBaseFramesetTemplate','common/frameset_floatingmenu_rtl.tpl');
else $smarty->assign('sBaseFramesetTemplate','common/frameset_floatingmenu_ltr.tpl');
$smarty->assign('sMenuFrameSource','src="main/menubar2.php"');
$smarty->assign('sStartFrameSource',"src=\"main/indexframe.php?boot=1&lang=$lang&egal=$egal&cookie=$cookie&sid=$sid&mask=2\"");
}else{
$smarty->assign('sStartFrameSource',"src = \"main/indexframe.php?boot=1&mask=$mask&lang=$lang&cookie=$cookie&sid=$sid\"");
#
# Assign frame dimensions
#
$smarty->assign('gui_frame_left_nav_width',$GLOBALCONFIG['gui_frame_left_nav_width']);
$smarty->assign('gui_frame_left_nav_border',$GLOBALCONFIG['gui_frame_left_nav_border']);
if($lang=='ar'||$lang=='fa') {
$smarty->assign('sBaseFramesetTemplate','common/frameset_rtl.tpl');
//require('gui/html_template/righttoliftdefault/tp_index.php');
} else{
#
# Else use normal frameset design
#
$smarty->assign('sBaseFramesetTemplate','common/frameset_ltr.tpl');
}
}
#
# Display the frame page
#
$smarty->display('common/baseframe.tpl');
?>