Subversion Repositories ALCASAR

Rev

Rev 2461 | Rev 2465 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log

Rev 2461 Rev 2462
Line 1... Line 1...
1
<?php
1
<?php
2
# $Id: ldap.php 2461 2017-12-14 23:01:41Z richard $
2
# $Id: ldap.php 2462 2017-12-15 14:26:24Z tom.houdayer $
3
 
3
 
4
/* written by steweb57, Rexy & Tom HOUDAYER */
4
/* written by steweb57, Rexy & Tom HOUDAYER */
5
/****************************************************************
5
/****************************************************************
6
*			GLOBAL FILE PATHS			*
6
*			GLOBAL FILE PATHS			*
7
*****************************************************************/
7
*****************************************************************/
Line 275... Line 275...
275
	<title><?= $l_ldap_title ?></title>
275
	<title><?= $l_ldap_title ?></title>
276
	<link type="text/css" href="/css/style.css" rel="stylesheet">
276
	<link type="text/css" href="/css/style.css" rel="stylesheet">
277
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
277
	<link type="text/css" href="/css/acc.css" rel="stylesheet">
278
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
278
	<link type="text/css" href="/css/ldap.css" rel="stylesheet">
279
	<script>
279
	<script>
280
	function onPageLoad() {
-
 
281
		onLdapStatusChange();
-
 
282
		if (document.getElementById('auth_enable').value === '1') {
-
 
283
			checkConfig();
-
 
284
		}
-
 
285
	}
-
 
286
 
-
 
287
	function onLdapStatusChange() {
280
	function onLdapStatusChange() {
288
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
281
		var listToDisables = ['ldap_server', 'ldap_dn', 'ldap_uid', 'ldap_base_filter', 'ldap_user', 'ldap_password'];
289
		var formSubmit = document.querySelector('form input[type="submit"]');
282
		var formSubmit = document.querySelector('form input[type="submit"]');
290
		var btn_checkConf = document.getElementById('btn-checkconf');
283
		var btn_checkConf = document.getElementById('btn-checkconf');
291
		var isChecked = false;
284
		var isChecked = false;
Line 306... Line 299...
306
			btn_checkConf.style.display = 'none';
299
			btn_checkConf.style.display = 'none';
307
		}
300
		}
308
	}
301
	}
309
 
302
 
310
	function checkConfig() {
303
	function checkConfig() {
311
		var messagesElem = document.querySelector('fieldset > legend > div:last-child');
304
		var messagesElem = document.querySelector('fieldset > legend > div');
312
		var formSubmit   = document.querySelector('form input[type="submit"]');
305
		var formSubmit   = document.querySelector('form input[type="submit"]');
313
		var btn_checkConf = document.getElementById('btn-checkconf');
306
		var btn_checkConf = document.getElementById('btn-checkconf');
314
 
307
 
315
		var ldap_config = {
308
		var ldap_config = {
316
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
309
			ldap_status:     (document.getElementById('auth_enable').value === '1'),
Line 320... Line 313...
320
			ldap_base_dn:     document.getElementById('ldap_dn').value,
313
			ldap_base_dn:     document.getElementById('ldap_dn').value,
321
			ldap_uid:         document.getElementById('ldap_uid').value,
314
			ldap_uid:         document.getElementById('ldap_uid').value,
322
			ldap_base_filter: document.getElementById('ldap_base_filter').value
315
			ldap_base_filter: document.getElementById('ldap_base_filter').value
323
		};
316
		};
324
 
317
 
-
 
318
		// Format HTTP POST data
325
		var params = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
319
		var post_data = Object.keys(ldap_config).map( function (k) { return encodeURIComponent(k) + '=' + encodeURIComponent(ldap_config[k]) } ).join('&');
326
 
320
 
327
		messagesElem.innerHTML = '<?= 'Checking configuration...' /* TODO: need to translate */ ?>';
321
		messagesElem.innerHTML = '<?= 'Checking configuration...' /* TODO: need to translate */ ?>';
328
 
322
 
329
		var xhr = new XMLHttpRequest();
323
		var xhr = new XMLHttpRequest();
330
		xhr.onreadystatechange = function() {
324
		xhr.onreadystatechange = function() {
Line 375... Line 369...
375
				}
369
				}
376
			}
370
			}
377
		};
371
		};
378
		xhr.open('POST', 'ldap.php?conf_check', true);
372
		xhr.open('POST', 'ldap.php?conf_check', true);
379
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
373
		xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
380
		xhr.send(params);
374
		xhr.send(post_data);
381
	}
375
	}
382
	</script>
376
	</script>
383
</head>
377
</head>
384
<body onLoad="onPageLoad();">
378
<body onLoad="onLdapStatusChange();">
385
	<div class="panel">
379
	<div class="panel">
386
		<div class="panel-header"><?= $l_ldap_legend ?></div>
380
		<div class="panel-header"><?= $l_ldap_legend ?></div>
387
		<div class="panel-body">
381
		<div class="panel-body">
388
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
382
			<form name="config_ldap" method="POST" action="<?= htmlspecialchars($_SERVER['PHP_SELF']) ?>">
389
				<fieldset>
383
				<fieldset>
Line 392... Line 386...
392
						<div style="text-align: center">
386
						<div style="text-align: center">
393
							<?php if ($messages): ?>
387
							<?php if ($messages): ?>
394
								<?= $messages ?>
388
								<?= $messages ?>
395
							<?php endif; ?>
389
							<?php endif; ?>
396
						</div>
390
						</div>
397
						<div style="text-align: center"></div>
-
 
398
					</legend>
391
					</legend>
399
					<dl>
392
					<dl>
400
						<dt>
393
						<dt>
401
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
394
							<label for="auth_enable"><?= $l_ldap_auth_enable_label ?></label>
402
						</dt>
395
						</dt>