-
Notifications
You must be signed in to change notification settings - Fork 21
/
login.php
44 lines (38 loc) · 1.23 KB
/
login.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
<?php
/**
* Do the login/logout process
*/
require_once('inc/init.php');
$msg = $lang['msg_login'];
if(!empty($_REQUEST['username'])){
if (empty($_REQUEST['password'])) { $_REQUEST['password']=''; }
if (do_ldap_bind($_REQUEST['username'],$_REQUEST['password'])){
//create private address book if simple enough
if(preg_match('/ou=([^,]+)$/',$conf['privatebook'],$match)){
$privatedn = $conf['privatebook'].', '.$_SESSION['ldapab']['binddn'];
if(!@ldap_read($LDAP_CON,$privatedn,'')){
@ldap_add($LDAP_CON,$privatedn,
array('objectClass' => array ('organizationalUnit','top'),
'ou' => $match[1]));
}
}
//forward to next page
if(!empty($_SESSION['ldapab']['lastlocation'])){
header('Location: '.$_SESSION['ldapab']['lastlocation']);
}else{
header('Location: index.php');
}
exit;
}else{
$msg = $lang['msg_loginfail'];;
}
}else{
//logout
unset($_SESSION['ldapab']);
}
//prepare templates
tpl_std();
$smarty->assign('msg',$msg);
//display templates
header('Content-Type: text/html; charset=utf-8');
$smarty->display('login.tpl');