File: ldap-photo.php3

package info (click to toggle)
openldap2 2.0.23-6.3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 7,816 kB
  • ctags: 6,366
  • sloc: ansic: 86,391; sh: 9,816; makefile: 1,270; cpp: 1,107; sql: 838; php: 700; perl: 134; tcl: 40
file content (46 lines) | stat: -rw-r--r-- 1,239 bytes parent folder | download
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
<?
if (isset($base_dn)) {
//	echo urldecode ($base_dn)."<br>\n";
}
if (isset($cn)) {
//	echo urldecode ($cn)."<br>\n";
}
$link_identifier = ldap_connect("127.0.0.1");
$result_identifier = ldap_read($link_identifier, $base_dn, 'objectclass=*');
if(!$result_identifier) {
	echo "No results.\n";
}
else {
	$num_entries = ldap_count_entries($link_identifier, $result_identifier);
	if ($num_entries == 0) {
		echo "No results\n";
		return 1;
	}
	Header("Content-type: image/jpeg");
	$info = ldap_get_entries($link_identifier, $result_identifier);
	ldap_close($link_identifier);
	for ($i=0; $i<$info["count"]; $i++) {
//		echo $i;
		if ($info[$i]["cn"][0] == $cn) {
			//echo "<b>".$info[$i]["cn"][0]."</b><br>";
		}
		for ($j=0; $j<$info[$i]["count"]; $j++) {
			$attribute = $info[$i][$j];
			if (strtolower ($attribute) == "jpegphoto") {
			//	$file = fopen("/tmp/tmpphoto.jpg", "w");
			//	echo $info[$i]["jpegphoto"][0];
				$p = $info[$i]["jpegphoto"][0];
				$photo = base64_decode($p);
				echo $photo;
			//	fwrite($file, $photo);
			//	flush();
			//	fclose($file);
			//	$file = fopen("/tmp/tmpphoto.jpg", r);
			//	$contents = fread ($file, filesize("/tmp/tmpphoto.jpg"));
			//	fclose($file);
			//	echo $contents;
			}
		}
	}
}
?>