|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* EGroupware Setup |
|
4
|
|
|
* |
|
5
|
|
|
* @link http://www.egroupware.org |
|
6
|
|
|
* @package setup |
|
7
|
|
|
* @author Tony Puglisi (Angles) <[email protected]> |
|
8
|
|
|
* @author Miles Lott <[email protected]> |
|
9
|
|
|
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> |
|
10
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License |
|
11
|
|
|
* @version $Id$ |
|
12
|
|
|
*/ |
|
13
|
|
|
|
|
14
|
|
|
use EGroupware\Api; |
|
15
|
|
|
|
|
16
|
|
|
/** |
|
17
|
|
|
* Some static helper functions to generate html stuff in setup |
|
18
|
|
|
*/ |
|
19
|
|
|
class setup_html |
|
20
|
|
|
{ |
|
21
|
|
|
/** |
|
22
|
|
|
* generate header.inc.php file output - NOT a generic html header function |
|
23
|
|
|
* |
|
24
|
|
|
*/ |
|
25
|
|
|
static function generate_header() |
|
26
|
|
|
{ |
|
27
|
|
|
// PHP will automatically replace any dots in incoming |
|
28
|
|
|
// variable names with underscores. |
|
29
|
|
|
|
|
30
|
|
|
$GLOBALS['header_template']->set_file(array('header' => 'header.inc.php.template')); |
|
31
|
|
|
$GLOBALS['header_template']->set_block('header','domain','domain'); |
|
32
|
|
|
$var = Array(); |
|
33
|
|
|
|
|
34
|
|
|
$deletedomain = $_POST['deletedomain']; |
|
35
|
|
|
$domains = $_POST['domains']; |
|
36
|
|
|
|
|
37
|
|
|
foreach($domains as $k => $v) |
|
38
|
|
|
{ |
|
39
|
|
|
if(is_array($deletedomain) && isset($deletedomain[$k])) |
|
40
|
|
|
{ |
|
41
|
|
|
continue; |
|
42
|
|
|
} |
|
43
|
|
|
$variableName = str_replace('.','_',$k); |
|
44
|
|
|
$dom = $_POST['setting_'.$variableName]; |
|
45
|
|
|
$GLOBALS['header_template']->set_var('DB_DOMAIN',$v); |
|
46
|
|
|
foreach($dom as $x => $y) |
|
47
|
|
|
{ |
|
48
|
|
|
if(strtoupper($x) == 'CONFIG_PASS') |
|
49
|
|
|
{ |
|
50
|
|
|
$GLOBALS['header_template']->set_var(strtoupper($x),md5($y)); |
|
51
|
|
|
} |
|
52
|
|
|
else |
|
53
|
|
|
{ |
|
54
|
|
|
$GLOBALS['header_template']->set_var(strtoupper($x),$y); |
|
55
|
|
|
} |
|
56
|
|
|
} |
|
57
|
|
|
/* Admin did not type a new password, so use the old one from the hidden field, |
|
58
|
|
|
* which is already md5 encoded. |
|
59
|
|
|
*/ |
|
60
|
|
|
if($dom['config_password'] && !$dom['config_pass']) |
|
61
|
|
|
{ |
|
62
|
|
|
/* Real == hidden */ |
|
63
|
|
|
$GLOBALS['header_template']->set_var('CONFIG_PASS',$dom['config_password']); |
|
64
|
|
|
} |
|
65
|
|
|
/* If the admin didn't select a db_port, set to the default */ |
|
66
|
|
|
if(!$dom['db_port']) |
|
67
|
|
|
{ |
|
68
|
|
|
$GLOBALS['header_template']->set_var('DB_PORT',$GLOBALS['default_db_ports'][$dom['db_type']]); |
|
69
|
|
|
} |
|
70
|
|
|
$GLOBALS['header_template']->parse('domains','domain',True); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
$GLOBALS['header_template']->set_var('domain',''); |
|
74
|
|
|
|
|
75
|
|
|
$setting = $_POST['setting']; |
|
76
|
|
|
foreach($setting as $k => $v) |
|
77
|
|
|
{ |
|
78
|
|
|
if(strtoupper($k) == 'HEADER_ADMIN_PASSWORD') |
|
79
|
|
|
{ |
|
80
|
|
|
$var[strtoupper($k)] = md5($v); |
|
81
|
|
|
} |
|
82
|
|
|
else |
|
83
|
|
|
{ |
|
84
|
|
|
$var[strtoupper($k)] = $v; |
|
85
|
|
|
} |
|
86
|
|
|
} |
|
87
|
|
|
/* Admin did not type a new header password, so use the old one from the hidden field, |
|
88
|
|
|
* which is already md5 encoded. |
|
89
|
|
|
*/ |
|
90
|
|
|
if($var['HEADER_ADMIN_PASS'] && empty($setting['HEADER_ADMIN_PASSWORD'])) |
|
91
|
|
|
{ |
|
92
|
|
|
/* Real == hidden */ |
|
93
|
|
|
$var['HEADER_ADMIN_PASSWORD'] = $var['HEADER_ADMIN_PASS']; |
|
94
|
|
|
} |
|
95
|
|
|
$GLOBALS['header_template']->set_var($var); |
|
96
|
|
|
return $GLOBALS['header_template']->parse('out','header'); |
|
97
|
|
|
} |
|
98
|
|
|
|
|
99
|
|
|
static function setup_tpl_dir($app_name='setup') |
|
100
|
|
|
{ |
|
101
|
|
|
/* hack to get tpl dir */ |
|
102
|
|
|
if (is_dir(EGW_SERVER_ROOT)) |
|
103
|
|
|
{ |
|
104
|
|
|
$srv_root = EGW_SERVER_ROOT . '/' . $app_name . '/'; |
|
105
|
|
|
} |
|
106
|
|
|
else |
|
107
|
|
|
{ |
|
108
|
|
|
$srv_root = ''; |
|
109
|
|
|
} |
|
110
|
|
|
|
|
111
|
|
|
$tpl_typical = 'templates/default'; |
|
112
|
|
|
$tpl_root = "$srv_root" ."$tpl_typical"; |
|
113
|
|
|
return $tpl_root; |
|
114
|
|
|
} |
|
115
|
|
|
|
|
116
|
|
|
static function show_header($title='',$nologoutbutton=False, $logoutfrom='config', $configdomain='') |
|
117
|
|
|
{ |
|
118
|
|
|
// add a content-type header to overwrite an existing default charset in apache (AddDefaultCharset directiv) |
|
119
|
|
|
header('Content-type: text/html; charset='.$GLOBALS['egw_setup']->system_charset); |
|
120
|
|
|
|
|
121
|
|
|
$GLOBALS['setup_tpl']->set_var('charset',$GLOBALS['egw_setup']->system_charset); |
|
122
|
|
|
$style = array( |
|
123
|
|
|
'th_bg' => '#486591', |
|
124
|
|
|
'th_text' => '#FFFFFF', |
|
125
|
|
|
'row_on' => '#DDDDDD', |
|
126
|
|
|
'row_off' => '#EEEEEE', |
|
127
|
|
|
'banner_bg' => '#4865F1', |
|
128
|
|
|
'msg' => '#FF0000', |
|
129
|
|
|
); |
|
130
|
|
|
$GLOBALS['setup_tpl']->set_var($style); |
|
131
|
|
|
if ($nologoutbutton) |
|
132
|
|
|
{ |
|
133
|
|
|
$GLOBALS['setup_tpl']->set_block('T_head','loged_in'); |
|
134
|
|
|
$GLOBALS['setup_tpl']->set_var('loged_in',''); |
|
135
|
|
|
} |
|
136
|
|
|
else |
|
137
|
|
|
{ |
|
138
|
|
|
$btn_logout = '<a href="index.php?FormLogout=' . $logoutfrom . '" class="link">' . lang('Logout').'</a>'; |
|
139
|
|
|
$check_install = '<a class="textsidebox" href="check_install.php">'.lang('Check installation').'</a>'; |
|
140
|
|
|
$register_hooks = '<a class="textsidebox" href="applications.php?hooks=1">'.lang('Clear cache and register hooks').'</a>'; |
|
141
|
|
|
} |
|
142
|
|
|
|
|
143
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_setup', lang('setup')); |
|
144
|
|
|
$GLOBALS['setup_tpl']->set_var('page_title',$title); |
|
145
|
|
|
if ($configdomain == '') |
|
146
|
|
|
{ |
|
147
|
|
|
$GLOBALS['setup_tpl']->set_var('configdomain',''); |
|
148
|
|
|
} |
|
149
|
|
|
else |
|
150
|
|
|
{ |
|
151
|
|
|
$GLOBALS['setup_tpl']->set_var('configdomain',' - ' . lang('Domain') . ': ' . $configdomain); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
if(basename($_SERVER['SCRIPT_FILENAME']) != 'index.php') |
|
155
|
|
|
{ |
|
156
|
|
|
$index_btn = '<a href="index.php" class="link">' . lang('Setup Main Menu') . '</a>'; |
|
157
|
|
|
$index_img = '<img src="../api/templates/default/images/bullet.png" />'; |
|
158
|
|
|
} |
|
159
|
|
|
|
|
160
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_version',lang('version')); |
|
161
|
|
|
if (!isset($GLOBALS['setup_info']) || !isset($GLOBALS['setup_info']['api']) || |
|
162
|
|
|
!isset($GLOBALS['setup_info']['api']['versions']) || !isset($GLOBALS['setup_info']['api']['versions']['maintenance_release'])) |
|
163
|
|
|
{ |
|
164
|
|
|
include(EGW_SERVER_ROOT.'/api/setup/setup.inc.php'); |
|
165
|
|
|
} |
|
166
|
|
|
else |
|
167
|
|
|
{ |
|
168
|
|
|
$setup_info = $GLOBALS['setup_info']; |
|
169
|
|
|
} |
|
170
|
|
|
$GLOBALS['setup_tpl']->set_var('pgw_ver', $nologoutbutton ? |
|
171
|
|
|
(double)$setup_info['api']['version'] : // without login only show main version, not maintenance release |
|
172
|
|
|
$setup_info['api']['versions']['maintenance_release']); |
|
173
|
|
|
|
|
174
|
|
|
$GLOBALS['setup_tpl']->set_var(array( |
|
175
|
|
|
'logoutbutton' => $btn_logout, |
|
176
|
|
|
'indexbutton' => $index_btn, |
|
177
|
|
|
'indeximg' => $index_img, |
|
178
|
|
|
'check_install' => $check_install, |
|
179
|
|
|
'register_hooks'=> $register_hooks, |
|
180
|
|
|
'main_menu' => lang('Setup Main Menu'), |
|
181
|
|
|
'user_login' => lang('Back to user login'), |
|
182
|
|
|
'help_menu' => lang('Help and support'), |
|
183
|
|
|
'documentation' => lang('Documentation'), |
|
184
|
|
|
'commercial_support' => lang('Commercial support'), |
|
185
|
|
|
'community_forum' => lang('Community forum'), |
|
186
|
|
|
)); |
|
187
|
|
|
|
|
188
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_head'); |
|
189
|
|
|
} |
|
190
|
|
|
|
|
191
|
|
|
static function show_footer() |
|
192
|
|
|
{ |
|
193
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_footer'); |
|
194
|
|
|
unset($GLOBALS['setup_tpl']); |
|
195
|
|
|
} |
|
196
|
|
|
|
|
197
|
|
|
static function show_alert_msg($alert_word='Setup alert',$alert_msg='setup alert (generic)') |
|
198
|
|
|
{ |
|
199
|
|
|
$GLOBALS['setup_tpl']->set_var('V_alert_word',$alert_word); |
|
200
|
|
|
$GLOBALS['setup_tpl']->set_var('V_alert_msg',$alert_msg); |
|
201
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_alert_msg'); |
|
202
|
|
|
} |
|
203
|
|
|
|
|
204
|
|
|
static function make_frm_btn_simple($pre_frm_blurb='',$frm_method='post',$frm_action='',$input_type='submit',$input_value='',$post_frm_blurb='') |
|
205
|
|
|
{ |
|
206
|
|
|
/* a simple form has simple components */ |
|
207
|
|
|
$simple_form = $pre_frm_blurb ."\n" |
|
208
|
|
|
. '<form method="' . $frm_method . '" action="' . $frm_action . '">' . "\n" |
|
209
|
|
|
. '<input type="' . $input_type . '" value="' . $input_value . '" />' . "\n" |
|
210
|
|
|
. '</form>' . "\n" |
|
211
|
|
|
. $post_frm_blurb . "\n"; |
|
212
|
|
|
return $simple_form; |
|
213
|
|
|
} |
|
214
|
|
|
|
|
215
|
|
|
static function make_href_link_simple($pre_link_blurb='',$href_link='',$href_text='default text',$post_link_blurb='') |
|
216
|
|
|
{ |
|
217
|
|
|
/* a simple href link has simple components */ |
|
218
|
|
|
$simple_link = $pre_link_blurb |
|
219
|
|
|
. '<a href="' . $href_link . '">' . $href_text . '</a> ' |
|
220
|
|
|
. $post_link_blurb . "\n"; |
|
221
|
|
|
return $simple_link; |
|
222
|
|
|
} |
|
223
|
|
|
|
|
224
|
|
|
static function login_form() |
|
225
|
|
|
{ |
|
226
|
|
|
/* begin use TEMPLATE login_main.tpl */ |
|
227
|
|
|
$GLOBALS['setup_tpl']->set_var('ConfigLoginMSG',@$GLOBALS['egw_info']['setup']['ConfigLoginMSG']); |
|
228
|
|
|
$GLOBALS['setup_tpl']->set_var('HeaderLoginMSG',@$GLOBALS['egw_info']['setup']['HeaderLoginMSG']); |
|
229
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_header_username',lang('Header Username')); |
|
230
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_header_password',lang('Header Password')); |
|
231
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_header_login',lang('Header Admin Login')); |
|
232
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_config_login',lang('Setup/Config Admin Login')); |
|
233
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_config_username',lang('Config Username')); |
|
234
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_config_password',lang('Config Password')); |
|
235
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_domain',lang('Domain')); |
|
236
|
|
|
|
|
237
|
|
|
$GLOBALS['setup_tpl']->set_var('lang_select',self::lang_select()); |
|
238
|
|
|
|
|
239
|
|
|
if ($GLOBALS['egw_info']['setup']['stage']['header'] == '10') |
|
240
|
|
|
{ |
|
241
|
|
|
/* |
|
242
|
|
|
Begin use SUB-TEMPLATE login_stage_header, |
|
243
|
|
|
fills V_login_stage_header used inside of login_main.tpl |
|
244
|
|
|
*/ |
|
245
|
|
|
if (count($GLOBALS['egw_domain']) > 1) |
|
246
|
|
|
{ |
|
247
|
|
|
foreach(array_keys($GLOBALS['egw_domain']) as $domain) |
|
248
|
|
|
{ |
|
249
|
|
|
$domains .= "<option value=\"$domain\" ".($domain == @$GLOBALS['egw_info']['setup']['LastDomain'] ? ' selected="selected"' : '').">$domain</option>\n"; |
|
|
|
|
|
|
250
|
|
|
} |
|
251
|
|
|
$GLOBALS['setup_tpl']->set_var('domains',$domains); |
|
252
|
|
|
|
|
253
|
|
|
// use BLOCK B_multi_domain inside of login_stage_header |
|
254
|
|
|
$GLOBALS['setup_tpl']->parse('V_multi_domain','B_multi_domain'); |
|
255
|
|
|
// in this case, the single domain block needs to be nothing |
|
256
|
|
|
$GLOBALS['setup_tpl']->set_var('V_single_domain',''); |
|
257
|
|
|
} |
|
258
|
|
|
else |
|
259
|
|
|
{ |
|
260
|
|
|
reset($GLOBALS['egw_domain']); |
|
261
|
|
|
$default_domain = key($GLOBALS['egw_domain']); |
|
262
|
|
|
$GLOBALS['setup_tpl']->set_var('default_domain_zero',$default_domain); |
|
263
|
|
|
|
|
264
|
|
|
/* Use BLOCK B_single_domain inside of login_stage_header */ |
|
265
|
|
|
$GLOBALS['setup_tpl']->parse('V_single_domain','B_single_domain'); |
|
266
|
|
|
/* in this case, the multi domain block needs to be nothing */ |
|
267
|
|
|
$GLOBALS['setup_tpl']->set_var('V_multi_domain',''); |
|
268
|
|
|
} |
|
269
|
|
|
/* |
|
270
|
|
|
End use SUB-TEMPLATE login_stage_header |
|
271
|
|
|
put all this into V_login_stage_header for use inside login_main |
|
272
|
|
|
*/ |
|
273
|
|
|
$GLOBALS['setup_tpl']->parse('V_login_stage_header','T_login_stage_header'); |
|
274
|
|
|
} |
|
275
|
|
|
else |
|
276
|
|
|
{ |
|
277
|
|
|
/* begin SKIP SUB-TEMPLATE login_stage_header */ |
|
278
|
|
|
$GLOBALS['setup_tpl']->set_var('V_multi_domain',''); |
|
279
|
|
|
$GLOBALS['setup_tpl']->set_var('V_single_domain',''); |
|
280
|
|
|
$GLOBALS['setup_tpl']->set_var('V_login_stage_header',''); |
|
281
|
|
|
} |
|
282
|
|
|
/* |
|
283
|
|
|
end use TEMPLATE login_main.tpl |
|
284
|
|
|
now out the login_main template |
|
285
|
|
|
*/ |
|
286
|
|
|
$GLOBALS['setup_tpl']->pparse('out','T_login_main'); |
|
287
|
|
|
} |
|
288
|
|
|
|
|
289
|
|
|
static function lang_select($onChange=False,$ConfigLang='') |
|
290
|
|
|
{ |
|
291
|
|
|
if (empty($ConfigLang)) |
|
292
|
|
|
{ |
|
293
|
|
|
$ConfigLang = setup::get_lang(true); // true use Accept-Language header |
|
294
|
|
|
} |
|
295
|
|
|
return Api\Html::select('ConfigLang', $ConfigLang, Api\Translation::get_available_langs(false), true, |
|
296
|
|
|
$onChange ? ' onchange="this.form.submit();"' : ''); |
|
297
|
|
|
} |
|
298
|
|
|
|
|
299
|
|
|
static function get_template_list() |
|
300
|
|
|
{ |
|
301
|
|
|
$d = dir(EGW_SERVER_ROOT . '/phpgwapi/templates'); |
|
302
|
|
|
|
|
303
|
|
|
$list = array(); |
|
304
|
|
|
while($entry = $d->read()) |
|
305
|
|
|
{ |
|
306
|
|
|
if ($entry != 'CVS' && $entry != '.' && $entry != '..') |
|
307
|
|
|
{ |
|
308
|
|
|
$list[$entry]['name'] = $entry; |
|
309
|
|
|
$f = EGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php'; |
|
310
|
|
|
if (file_exists ($f)) |
|
311
|
|
|
{ |
|
312
|
|
|
include($f); |
|
313
|
|
|
$list[$entry]['title'] = 'Use ' . $GLOBALS['egw_info']['template'][$entry]['title'] . 'interface'; |
|
314
|
|
|
} |
|
315
|
|
|
else |
|
316
|
|
|
{ |
|
317
|
|
|
$list[$entry]['title'] = $entry; |
|
318
|
|
|
} |
|
319
|
|
|
} |
|
320
|
|
|
} |
|
321
|
|
|
$d->close(); |
|
322
|
|
|
reset ($list); |
|
323
|
|
|
return $list; |
|
324
|
|
|
} |
|
325
|
|
|
|
|
326
|
|
|
static function list_themes() |
|
327
|
|
|
{ |
|
328
|
|
|
$dh = dir(EGW_SERVER_ROOT . '/phpgwapi/themes'); |
|
329
|
|
|
while ($file = $dh->read()) |
|
330
|
|
|
{ |
|
331
|
|
|
if (preg_match('/'."\.theme$".'/i', $file)) |
|
332
|
|
|
{ |
|
333
|
|
|
$list[] = substr($file,0,strpos($file,'.')); |
|
334
|
|
|
} |
|
335
|
|
|
} |
|
336
|
|
|
$dh->close(); |
|
337
|
|
|
reset ($list); |
|
338
|
|
|
return $list; |
|
339
|
|
|
} |
|
340
|
|
|
} |
|
341
|
|
|
|