if(empty($dn)){
//anonymous bind to lookup users
//blank binddn or blank bindpw will result in anonymous bind
- if(!ldap_bind($LDAP_CON,$conf['anonbinddn'],$conf['anonbindpw'])){
+ if(!@ldap_bind($LDAP_CON,$conf['anonbinddn'],$conf['anonbindpw'])){
die("can not bind for user lookup");
}
}
//bind with dn
- if(ldap_bind($LDAP_CON,$dn,$pass)){
+ if(@ldap_bind($LDAP_CON,$dn,$pass)){
//bind successful -> set up session
set_session($user,$pass,$dn);
return true;
* cookies; the string is stored inside the cache dir
*/
function get_cookie_secret(){
- $file = dirname(__FILE__).'/cache/.htcookiesecret.php';
+ $file = dirname(__FILE__).'/../cache/.htcookiesecret.php';
if(@file_exists($file)){
return md5(trim(file($file)));
}
$out[$FIELDS["_$key"]][] = $value; //shouldn't happen, but to be sure
}
}else{
- // no mapping found - assume it to be a LDAP attribute (shouldn't happen)
- if(is_array($value)){
- $out[$key] = $value;
- }else{
- $out[$key][] = $value;
- }
+ // no mapping found we ignore it
}
}
}
}
+/**
+ * Returns all the fields used in the template
+ *
+ * Returned fields are already decoded to LDAP internals
+ */
+function get_fields_from_template($tpl){
+ global $smarty;
+ global $FIELDS;
+ $tpl = $smarty->template_dir.'/'.$tpl;
+ $data = @file_get_contents($tpl);
+ $matches = array();
+ preg_match_all('/\$entry\.(\w+)/',$data,$matches);
+ $matches = array_unique((array) $matches[1]);
+ $return = array();
+ foreach($matches as $f){
+ if($FIELDS[$f]){
+ $return[] = $FIELDS[$f];
+ }elseif($FIELDS["_$f"]){
+ $return[] = $FIELDS["_$f"];
+ }
+ }
+ return $return;
+}
?>