2009-06-30 08:07:14 +00:00
|
|
|
<?php
|
2009-07-01 06:09:17 +00:00
|
|
|
// $Header$
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Download a binary value attribute to the user.
|
|
|
|
* A server ID, DN and Attribute must be provided in the GET attributes.
|
|
|
|
* Optionally an index, type and filename can be supplied.
|
|
|
|
*
|
2009-06-30 09:29:51 +00:00
|
|
|
* @package phpLDAPadmin
|
2009-07-01 06:09:17 +00:00
|
|
|
* @subpackage Page
|
2009-06-30 09:29:51 +00:00
|
|
|
*/
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
/**
|
|
|
|
*/
|
2009-06-30 09:22:30 +00:00
|
|
|
|
|
|
|
require './common.php';
|
2009-06-30 08:07:14 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request = array();
|
|
|
|
$request['dn'] = get_request('dn','GET');
|
|
|
|
$request['attr'] = strtolower(get_request('attr','GET',true));
|
|
|
|
$request['index'] = get_request('index','GET',false,0);
|
|
|
|
$request['type'] = get_request('type','GET',false,'octet-stream');
|
|
|
|
$request['filename'] = get_request('filename','GET',false,sprintf('%s:%s.bin',get_rdn($request['dn'],true),$request['attr']));
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! $app['server']->dnExists($request['dn']))
|
|
|
|
error(sprintf(_('The entry (%s) does not exist.'),$request['dn']),'error','index.php');
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$search = $app['server']->getDNAttrValues($request['dn'],null,LDAP_DEREF_NEVER,array($request['attr']));
|
2009-06-30 09:29:51 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
# Dump the binary data to the browser
|
2009-06-30 11:52:55 +00:00
|
|
|
$obStatus = ob_get_status();
|
|
|
|
if (isset($obStatus['type']) && $obStatus['type'] && $obStatus['status'])
|
|
|
|
ob_end_clean();
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
if (! isset($search[$request['attr']][$request['index']])) {
|
|
|
|
# We cant display an error, but we can set a system message, which will be display on the next page render.
|
|
|
|
system_message(array(
|
|
|
|
'title'=>_('No binary data available'),
|
|
|
|
'body'=>sprintf(_('Could not fetch binary data from LDAP server for attribute [%s].'),$request['attr']),
|
|
|
|
'type'=>'warn'));
|
|
|
|
|
|
|
|
die();
|
|
|
|
}
|
|
|
|
|
|
|
|
header(sprintf('Content-type: %s',$request['type']));
|
|
|
|
header(sprintf('Content-disposition: attachment; filename="%s"',$request['filename']));
|
|
|
|
header(sprintf('Expires: Mon, 26 Jul 1997 05:00:00 GMT',gmdate('r')));
|
|
|
|
header(sprintf('Last-Modified: %s',gmdate('r')));
|
|
|
|
echo $search[$request['attr']][$request['index']];
|
|
|
|
die();
|
2009-06-30 08:07:14 +00:00
|
|
|
?>
|