-
Notifications
You must be signed in to change notification settings - Fork 0
/
admin.php
269 lines (213 loc) · 8.41 KB
/
admin.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
<?php
session_start();
header('Content-Type: text/html; charset=utf-8');
//include('./system/config.php');
// from autocomplete
if( file_exists( "./system/config" ) ) { // Does a Config File exist
require( "./system/systemconfig.class.php" );
$_sC = new systemConfig( "./system/config" );
switch( $_sC->_get('db_type') ) {
case 'mysql': require_once( $_sC->_get('path_system') ."mysql.class.php" ); break;
case 'postgresql': require_once( $_sC->_get('path_system') ."pgsql.class.php" ); break;
default: die("No Database Type was set!");
}
# Local database connection
$db = db::getInstance();
$db->_set("server", $_sC->_get("db_server"));
$db->_set("port", $_sC->_get("db_port"));
$db->_set("user", $_sC->_get("db_user"));
$db->_set("password",$_sC->_get("db_password"));
$db->_set("database",$_sC->_get("db_database"));
$db->_set("coding", $_sC->_get("db_encoding"));
$db->connect();
require( $_sC->_get( 'path_system' ) . 'functions.php' );
require( $_sC->_get( 'path_system' ) . 'translate.class.php' );
require( $_sC->_get( 'path_system' ) . 'user.class.php' );
require( $_sC->_get( 'path_system' ) . 'filemanager.class.php' );
require_once($_sC->_get('path_helpers').'form.helper.php');
require_once($_sC->_get('path_helpers').'table.helper.php');
// Translater object
$translater = new translater();
} else {
die("<p>The config file couldnt by found! Please create one!");
}
$templateFile = file_get_contents($_sC->_get('path_templates').'main_template.html');
/*****************************************************
* Content Processing Start
*
*****************************************************/
$user = new adminUser();
ob_start();
// login data send
if( isset( $_POST['f_login'] ) ) {
// user exist and password passed
if( false === $result = $user->login($_POST['f_username'],$_POST['f_password']) ) {
echo '<p class="error">{L:system:wrong_password}</p>';
}}
// logout
if( isset($_GET['logout']) && filter_var($_GET['logout'],FILTER_VALIDATE_BOOLEAN) ){
$user->logout(); // destroy session
header('location: '. $_sC->_get('domain').'admin.php'); // reload site
}
if( false == $user->isLoaded() ) { // no user
$form = new form(); // new login form
$form->form_target = './admin.php';
$form->form_method = 'POST';
$form->form_id = 'login_form';
$form->form_fields = array( // form fields
'fieldset' => 'login',
'legend' => '{L:system:login_form}',
'fields' => array(
array('type'=>'text','name'=>'username','label'=>'{L:system:username}'),
array('type'=>'password','name'=>'password','label'=>'{L:system:password}'),
array('type'=>'submit','name'=>'login','class'=>'btt login', 'value'=>'{L:system:login}')
)
);
echo $form->create_output();
} else { // user is logged in
if( isset($_GET['mod']) ) {
include($_sC->_get('path_modules') .$_GET['mod'].'/default.php' );
if( file_exists($_sC->_get('path_modules') .$_GET['mod'].'/lang/de.txt') ) {
$translater->addFile($_sC->_get('path_modules') .$_GET['mod'].'/lang/de.txt');
}
}
}
$content = ob_get_contents();
if( $_sC->_get('debug') == TRUE ) {
$content .= "<div style='position:absolute; top: 50px; right:0px; border:1px solid #DDD; background-color: #EFEFEF; font-size:10pt;'>\n"
. "<strong>DEBUG INFO</strong><br />\n"
. "<i>Configuration</i><br />\n"
. nl2br( $_sC->showVariables(TRUE) )
. "<i>_POST Vars</i><br />\n"
. nl2br( print_r( $_POST, true ) )
. "<i>_GET Vars</i><br />\n"
. nl2br( print_r( $_GET, true ) )
. "<i>_SESSION Vars</i><br />\n"
. nl2br( print_r( $_SESSION, true ) )
. "</div>";
}
ob_end_clean();
/*****************************************************
*
* Content Processing End
****************************************************/
$styleLinks = '<link href="'.$_sC->_get('domain').'templates/css/admin.css" rel="stylesheet" type="text/css" media="screen" />';
$markers = array(
"###TITLE###" => $_sC->_get('system_title'),
"###LOGINFORM###" => $loginFormResult,
"###TOPNAVIGATION###" => !$user->isLoaded() ? '' :'<ul><li><a href="?mod=sys_import">{L:system:import}</a></li><li><a href="?mod=sys_overview">{L:system:analyse_overview}</a></li><li><a href="?mod=sys_datasheets">{L:system:datasheet}</a></li><li><a href="?mod=sys_datagroups">{L:system:datagroups}</a></li></ul>' ,
"###NAVIGATION###" => !$user->isLoaded() ? '' : $navigation,
"###CONTENT###" => $content,
"###BORDER_CONTENT###" => $border_content,
"###CSSSTYLES###" => $styleLinks,
'###JSFILE1###' => 'http://code.jquery.com/jquery-1.9.1.js',
'###JSFILE2###' => 'http://code.jquery.com/ui/1.10.2/jquery-ui.js',
'###USERNAVIGATION###' => null
);
if( $user->isLoaded() ) {
$markers['###USERNAVIGATION###'] = '<div class="user_nav"> <a href="'.$_sC->_get('domain').'" target="_blank">Frontend</a> <a href="#" title="{L:user:last_login} '. date($_sC->_get('datetime_format'),$user->_get('last_login')).'">' . $user->_get('name') . ' ' . $user->_get('surname') . '</a>'
. ' <a href="?logout=1">{L:system:logout}</a> </div>';
}
$mainTemp = getSubpart($templateFile,'###MAINTEMPLATE###');
$html_output = substituteMarkerArray($mainTemp,$markers);
$html_output = $translater->translate($html_output);
print( $html_output );
$db->close();
function processCSV($fullFilename, $firstLine=1){
global $rowCnt, $db;
$f = fopen($fullFilename,'r');
$linNr = 0;
while( ( $data = fgetcsv($f, 4096, ",", '"') ) !== false) {
if( $linNr < $firstLine){
$linNr++;
continue;
}
list($titel,$syn, $brand) = $data;
$synAr = explode( ';', $syn);
$brandAr = explode( ';', $brand);
$synC = count($synAr);
$brandC = count($brandAr);
$rowspan = 0;
if( $synC > $brandC ){
$rowspan = $synC;
}elseif( $synC < $brandC || $synC == $brandC ){
$rowspan = $brandC;
}
for($i=0; $i<$rowspan; $i++) {
if( FALSE === $db->select_row('brand','brands','brand="'.$brandAr[$i].'" OR synonym="'.$synAr[$i].'"') ) {
$row = array(
'name' => $titel,
'synonym' => (isset($synAr[$i])?$synAr[$i]:null),
'brand' => (isset($brandAr[$i])?$brandAr[$i]:null)
);
if( false == $db->insert($row,'brands') )
break;
}
}
}
fclose($f);
}
function processDIMDI($fullFilename) {
global $rowCnt, $db;
require('./helpers/dimdi.helper.php'); // dimdi class file
$f = fopen($fullFilename,'r'); // open file handler
$dimdi = new dimdi(); // new dimdi object
$linNr = 0; // line count
while (($data = fgets($f, 4096)) !== false ) { // read file by lines
$dimdi->addItem($data); // add data
$linNr++; // increase line count
}
// close file handler
fclose($f);
// Chapter
// chapter will not be saved in db yet
for( $k=1; $k<count($dimdi->result); $k++) {
// for every group in kapitel
foreach($dimdi->result[$k]['groups'] as $group_nr=>$group) {
//group data
$grRow = array(
'pid' => $k,
'group_nr' => $group_nr,
'group_name' => $group['name']
);
// save group to DB
if( $db->insert($grRow,'ICD10-groups') ) {
// group id
$groupId = $db->last_ID;
// every item in group
foreach($group['items'] as $item_nr=>$item) {
// define item data
$itRow = array(
'pid' => $groupId,
'item_nr' => $item_nr,
'item_name' => $item['text']
);
// save item in DB
if( $db->insert($itRow,'ICD10-items') ) {
// item id
$itId = $db->last_ID;
// Including Info for Item
if( isset($item['inc']) ) {
// save every single info
for($i=0; $i<count($item['inc']); $i++ ) {
if( false == $db->insert(array('pid'=>$itId,'typ'=>'I','text'=>$item['inc'][$i]),'ICD10-item_details') ) {
echo $db->error;
}
}
}
// Excluding Info for Item
if( isset($item['exc']) ) {
// save every single info
for($e=0; $e<count($item['inc']); $e++ ) {
if( false == $db->insert(array('pid'=>$itId,'typ'=>'E','text'=>$item['exc'][$e]),'ICD10-item_details') ) {
echo $db->error;
} // $db->insert( detail )
} // for( info )
} // exlude
} // $db->insert(item)
} // foreach group
} // $db->insert(group)
} // foreach group
} // for (chapter)
} //function
?>