Location: PHPKode > projects > LDAPted > ldapted/showImage.php
<?php
require ("includes/session.php");
require ("includes/LDAPinterface.php");
require ("includes/Config.php");

if ((!$_REQUEST['dn']) || (!$_REQUEST['type']) || (!$_REQUEST['attrib']))
{
  die("Missing important variables: dn=".$_REQUEST['dn']."; type=".$_REQUEST['type']."; attribute=".$_REQUEST['attrib']);
}

if ($_REQUEST['dn'] != "nopic")
{
	$ldap = new LDAPinterface($host,$bind_dn,$pw);

	$ldapSearchResult = ldap_search($ldap->connection, $_REQUEST['dn'], 'objectclass=*', array($_REQUEST['attrib']));
	 
	if ($a = ldap_count_entries($ldap->connection, $ldapSearchResult))
	{
		$ldapResults = ldap_get_entries($ldap->connection, $ldapSearchResult);
		$entry = ldap_first_entry($ldap->connection, $ldapSearchResult);
		$ldapBinary = ldap_get_values_len ($ldap->connection, $entry, $_REQUEST['attrib']);
		$image = $ldapBinary[0];
	}
}
else
{
  $config = new Config("config.xml");
  $options = $config->get_options();
  $mf = $options['templates'].$options['defskin'].'images/nopic.jpg';
  if (file_exists($mf)) {
    $fp = fopen($mf,"r");
    $image = fread ($fp, filesize($mf));
    fclose ($fp);
  }
}
header("Content-type: ".$_REQUEST['type']);
echo $image;
?>
Return current item: LDAPted