forked from polyspectra/OS_elabFTW
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sysconfig.php
346 lines (319 loc) · 15.8 KB
/
sysconfig.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
<?php
/**
* sysconfig.php
*
* @author Nicolas CARPi <[email protected]>
* @copyright 2012 Nicolas CARPi
* @see http://www.elabftw.net Official website
* @license AGPL-3.0
* @package elabftw
*/
namespace Elabftw\Elabftw;
use Exception;
/**
* Administrate elabftw install
*
*/
require_once 'inc/common.php';
try {
if ($_SESSION['is_sysadmin'] != 1) {
throw new Exception(_('This section is out of your reach.'));
}
$page_title = _('eLabFTW configuration');
$selected_menu = null;
require_once 'inc/head.php';
$formKey = new FormKey();
$crypto = new CryptoWrapper();
$SysconfigView = new SysconfigView(new Update(), new Logs(), new TeamsView());
$stamppass = get_config('stamppass');
$smtppass = get_config('smtp_password');
if (strlen($stamppass) > 0) {
$stamppass = $crypto->decrypt($stamppass);
}
if (strlen($smtppass) > 0) {
$smtppass = $crypto->decrypt($smtppass);
}
try {
// we put another try here because an exception here would end the page
// and not getting the latest version is not a big deal
$SysconfigView->Update->getUpdatesIni();
} catch (Exception $e) {
display_message('ko_nocross', $e->getMessage());
}
if ($SysconfigView->Update->success === true) {
// display current and latest version
echo "<br><p>" . _('Installed version:') . " " . $SysconfigView->Update->getInstalledVersion() . " ";
// show a little green check if we have latest version
if (!$SysconfigView->Update->updateIsAvailable()) {
echo "<img src='img/check.png' width='16px' length='16px' title='latest' style='position:relative;bottom:8px' alt='OK' />";
}
// display latest version
echo "<br>" . _('Latest version:') . " " . $SysconfigView->Update->getLatestVersion() . "</p>";
// if we don't have the latest version, show button redirecting to wiki
if ($SysconfigView->Update->updateIsAvailable()) {
$message = _('A new version is available!') . " <a href='doc/_build/html/how-to-update.html'>
<button class='button'>Update elabftw</button></a>";
display_message('warning', $message);
}
}
if (get_config('mail_from') === '[email protected]') {
$message = sprintf(_('Please finalize install : %slink to documentation%s.'), "<a href='doc/_build/html/postinstall.html#setting-up-email'>", "</a>");
display_message('ko', $message);
}
?>
<menu>
<ul>
<li class='tabhandle' id='tab1'><?php echo _('Teams'); ?></li>
<li class='tabhandle' id='tab2'><?php echo _('Server'); ?></li>
<li class='tabhandle' id='tab3'><?php echo _('Timestamp'); ?></li>
<li class='tabhandle' id='tab4'><?php echo _('Security'); ?></li>
<li class='tabhandle' id='tab5'><?php echo _('Email'); ?></li>
<li class='tabhandle' id='tab6'><?php echo _('Logs'); ?></li>
</ul>
</menu>
<!-- TAB 1 TEAMS -->
<div class='divhandle' id='tab1div'>
<div id='teamsDiv'>
<?php
echo $SysconfigView->TeamsView->showStats();
echo $SysconfigView->TeamsView->showPromoteSysadmin();
echo $SysconfigView->TeamsView->showCreate();
echo $SysconfigView->TeamsView->show();
?>
</div>
</div>
<!-- TAB 2 -->
<div class='divhandle' id='tab2div'>
<form class='box' method='post' action='app/sysconfig-exec.php'>
<h3><?php echo _('Under the hood'); ?></h3>
<label for='lang'><?php echo _('Language'); ?></label>
<select id='lang' name="lang">
<?php
$lang_array = array('en_GB', 'ca_ES', 'de_DE', 'es_ES', 'fr_FR', 'it_IT', 'pt_BR', 'zh_CN');
$current_lang = get_config('lang');
foreach ($lang_array as $lang) {
echo "<option ";
if ($current_lang === $lang) {
echo ' selected ';
}
echo "value='" . $lang . "'>" . $lang . "</option>";
}
?>
</select><br>
<label for='proxy'><?php echo _('Address of the proxy:'); ?></label>
<input type='text' value='<?php echo get_config('proxy'); ?>' name='proxy' id='proxy' />
<p class='smallgray'><?php echo _('If you are behind a firewall/proxy, enter the address here. Example : http://proxy.example.com:3128'); ?></p>
<div class='submitButtonDiv'>
<button type='submit' name='submit_config' class='button'><?php echo _('Save'); ?></button>
</div>
</form>
<div class='box'>
<h3><?php echo _('Informations'); ?></h3>
<ul>
<li><p><?php echo _('Operating System') . ': ' . PHP_OS; ?></p></li>
<li><p><?php echo _('PHP Version') . ': ' . PHP_VERSION; ?></p></li>
<li><p><?php echo _('Size of the uploads folder') . ': ' . Tools::formatBytes(Tools::dirSize(ELAB_ROOT . 'uploads')) .
' (' . Tools::dirNum(ELAB_ROOT . 'uploads') . ' files)'; ?></p></li>
<li><p><?php echo _('Largest integer supported') . ': ' . PHP_INT_MAX; ?></p></li>
<li><p><?php echo _('PHP configuration directory') . ': ' . PHP_SYSCONFDIR; ?></p></li>
</ul>
</div>
</div>
<!-- TAB 3 TIMESTAMP -->
<div class='divhandle' id='tab3div'>
<form class='box' method='post' action='app/sysconfig-exec.php'>
<h3><?php echo _('Timestamping configuration'); ?></h3>
<label for='stampshare'><?php echo _('The teams can use the credentials below to timestamp:'); ?></label>
<select name='stampshare' id='stampshare'>
<option value='1'<?php
if (get_config('stampshare') == 1) { echo " selected='selected'"; } ?>
><?php echo _('Yes'); ?></option>
<option value='0'<?php
if (get_config('stampshare') == 0) { echo " selected='selected'"; } ?>
><?php echo _('No'); ?></option>
</select>
<p class='smallgray'><?php echo _('You can control if the teams can use the global timestamping account. If set to <em>no</em> the team admin must add login infos in the admin panel.'); ?></p>
<p>
<label for='stampprovider'><?php echo _('URL for external timestamping service:'); ?></label>
<input type='url' placeholder='http://zeitstempel.dfn.de/' value='<?php echo get_config('stampprovider'); ?>' name='stampprovider' id='stampprovider' />
<span class='smallgray'><?php printf(_('This should be the URL used for %sRFC 3161%s-compliant timestamping requests.'), "<a href='https://tools.ietf.org/html/rfc3161'>", "</a>"); ?></span>
</p>
<p>
<label for='stampcert'><?php echo _('Chain of certificates of the external timestamping service:'); ?></label>
<input type='text' placeholder='vendor/pki.dfn.pem' value='<?php echo get_config('stampcert'); ?>' name='stampcert' id='stampcert' />
<span class='smallgray'><?php printf(_('This should point to the chain of certificates used by your external timestamping provider to sign the timestamps.%sLocal path relative to eLabFTW installation directory. The file needs to be in %sPEM-encoded (ASCII)%s format!'), "<br>", "<a href='https://en.wikipedia.org/wiki/Privacy-enhanced_Electronic_Mail'>", "</a>"); ?></span>
</p>
<label for='stamplogin'><?php echo _('Login for external timestamping service:'); ?></label>
<input type='text' value='<?php echo get_config('stamplogin'); ?>' name='stamplogin' id='stamplogin' /><br>
<label for='stamppass'><?php echo _('Password for external timestamping service:'); ?></label>
<input type='password' value='<?php echo $stamppass; ?>' name='stamppass' id='stamppass' />
<div class='submitButtonDiv'>
<button type='submit' name='submit_config' class='button'><?php echo _('Save'); ?></button>
</div>
</form>
</div>
<!-- TAB 4 SECURITY -->
<div class='divhandle' id='tab4div'>
<div class='box'>
<h3><?php echo _('Security settings'); ?></h3>
<form method='post' action='app/sysconfig-exec.php'>
<label for='admin_validate'><?php echo _('Users need validation by admin after registration:'); ?></label>
<select name='admin_validate' id='admin_validate'>
<option value='1'<?php
if (get_config('admin_validate') == 1) { echo " selected='selected'"; } ?>
><?php echo _('Yes'); ?></option>
<option value='0'<?php
if (get_config('admin_validate') == 0) { echo " selected='selected'"; } ?>
><?php echo _('No'); ?></option>
</select>
<p class='smallgray'><?php echo _('Set to yes for added security.'); ?></p>
<label for='login_tries'><?php echo _('Number of allowed login attempts:'); ?></label>
<input type='text' value='<?php echo get_config('login_tries'); ?>' name='login_tries' id='login_tries' />
<p class='smallgray'><?php echo _('3 might be too few. See for yourself :)'); ?></p>
<label for='ban_time'><?php echo _('Time of the ban after failed login attempts (in minutes:'); ?></label>
<input type='text' value='<?php echo get_config('ban_time'); ?>' name='ban_time' id='ban_time' />
<p class='smallgray'><?php echo _('To identify an user we use an md5 of user agent + IP. Because doing it only based on IP address would surely cause problems.'); ?></p>
<div class='submitButtonDiv'>
<button type='submit' name='submit_config' class='button'><?php echo _('Save'); ?></button>
</div>
</form>
</div>
</div>
<!-- TAB 5 -->
<div class='divhandle' id='tab5div'>
<div class='box'>
<h3><?php echo _('E-mail settings'); ?></h3>
<?php
$mail_method = get_config('mail_method');
switch ($mail_method) {
case 'sendmail':
$disable_sendmail = false;
$disable_smtp = true;
$disable_php = true;
break;
case 'smtp':
$disable_sendmail = true;
$disable_smtp = false;
$disable_php = true;
break;
case 'php':
$disable_sendmail = true;
$disable_smtp = true;
$disable_php = false;
break;
default:
$disable_sendmail = true;
$disable_smtp = true;
$disable_php = true;
} ?>
<form method='post' action='app/sysconfig-exec.php'>
<p><?php echo _("Without a valid way to send emails users won't be able to reset their password. It is recommended to create a specific Mailgun.com (or gmail account and add the infos here."); ?></p>
<p>
<label for='mail_method'><?php echo _('Send e-mails via:'); ?></label>
<select onchange='toggleMailMethod($("#toggle_main_method").val())' name='mail_method' id='toggle_main_method'>
<option value=''><?php echo _('Select mailing method...'); ?></option>
<option value='sendmail' <?php if (!$disable_sendmail) {
echo 'selected="selected"';
}
?>><?php echo _('Local MTA (default)'); ?></option>
<option value='smtp' <?php if (!$disable_smtp) {
echo 'selected="selected"';
}
?>><?php echo _('SMTP'); ?></option>
<option value='php' <?php if (!$disable_php) {
echo 'selected="selected"';
}
?>><?php echo _('PHP'); ?></option>
</select>
</p>
<div id='general_mail_config'>
<p>
<label for='mail_from'><?php echo _('Sender address:'); ?></label>
<input type='text' value='<?php echo get_config('mail_from'); ?>' name='mail_from' id='mail_from' />
</p>
</div>
<div id='sendmail_config'>
<p>
<label for='sendmail_path'><?php echo _('Path to sendmail:'); ?></label>
<input type='text' placeholder='/usr/bin/sendmail' value='<?php echo get_config('sendmail_path'); ?>' name='sendmail_path' id='sendmail_path' />
</p>
</div>
<div id='smtp_config'>
<p>
<label for='smtp_address'><?php echo _('Address of the SMTP server:'); ?></label>
<input type='text' value='<?php echo get_config('smtp_address'); ?>' name='smtp_address' id='smtp_address' />
</p>
<p>
<span class='smallgray'>smtp.mailgun.com</span>
<label for='smtp_encryption'><?php echo _('SMTP encryption (can be TLS or STARTSSL):'); ?></label>
<input type='text' value='<?php echo get_config('smtp_encryption'); ?>' name='smtp_encryption' id='smtp_encryption' />
</p>
<p>
<span class='smallgray'><?php echo _('Probably TLS'); ?></span>
<label for='smtp_port'><?php echo _('SMTP Port:'); ?></label>
<input type='text' value='<?php echo get_config('smtp_port'); ?>' name='smtp_port' id='smtp_port' />
</p>
<p>
<span class='smallgray'><?php echo _('Default is 587.'); ?></span>
<label for='smtp_username'><?php echo _('SMTP username:'); ?></label>
<input type='text' value='<?php echo get_config('smtp_username'); ?>' name='smtp_username' id='smtp_username' />
</p>
<p>
<label for='smtp_password'><?php echo _('SMTP password'); ?></label>
<input type='password' value='<?php echo $smtppass; ?>' name='smtp_password' id='smtp_password' />
</p>
</div>
<div class='submitButtonDiv'>
<button type='submit' name='submit_config' class='button'><?php echo _('Save'); ?></button>
</div>
</form>
</div>
<!-- TEST EMAIL -->
<?php echo $SysconfigView->testemailShow(); ?>
</div>
<!-- TAB 6 LOGS -->
<div class='divhandle' id='tab6div'>
<?php echo $SysconfigView->logsShow(); ?>
</div>
<script>
$(document).ready(function() {
// we need to add this otherwise the button will stay disabled with the browser's cache (Firefox)
var input_list = document.getElementsByTagName('input');
for (var i=0; i < input_list.length; i++) {
var input = input_list[i];
input.disabled = false;
}
// TABS
// get the tab=X parameter in the url
var params = getGetParameters();
var tab = parseInt(params['tab']);
if (!isInt(tab)) {
var tab = 1;
}
var initdiv = '#tab' + tab + 'div';
var inittab = '#tab' + tab;
// init
$(".divhandle").hide();
$(initdiv).show();
$(inittab).addClass('selected');
$(".tabhandle" ).click(function(event) {
var tabhandle = '#' + event.target.id;
var divhandle = '#' + event.target.id + 'div';
$(".divhandle").hide();
$(divhandle).show();
$(".tabhandle").removeClass('selected');
$(tabhandle).addClass('selected');
});
// END TABS
// honor already saved mail_method setting and hide unused options accordingly
toggleMailMethod(<?php echo json_encode($mail_method); ?>);
});
</script>
<?php
} catch (Exception $e) {
$Logs = new Logs();
$Logs->create('Error', $_SESSION['userid'], $e->getMessage());
display_message('ko', $e->getMessage());
} finally {
require_once 'inc/footer.php';
}