phpldapadmin/htdocs/download_binary_attr.php

46 lines
1.4 KiB
PHP
Raw Normal View History

2009-06-30 08:07:14 +00:00
<?php
2009-06-30 11:52:55 +00:00
// $Header: /cvsroot/phpldapadmin/phpldapadmin/htdocs/download_binary_attr.php,v 1.15.2.4 2008/12/12 12:20:22 wurley Exp $
2009-06-30 08:07:14 +00:00
2009-06-30 09:29:51 +00:00
/**
* @package phpLDAPadmin
* Variables that come in via common.php
* - server_id
*/
/**
*/
2009-06-30 09:22:30 +00:00
require './common.php';
2009-06-30 08:07:14 +00:00
2009-06-30 09:29:51 +00:00
if ($ldapserver->isReadOnly())
2009-06-30 11:52:55 +00:00
error(_('You cannot perform updates while server is in read-only mode'),'error','index.php');
2009-06-30 09:29:51 +00:00
if (! $ldapserver->haveAuthInfo())
2009-06-30 11:52:55 +00:00
error(_('Not enough information to login to server. Please check your configuration.'),'error','index.php');
2009-06-30 09:29:51 +00:00
2009-06-30 11:52:55 +00:00
$dn = rawurldecode(get_request('dn','GET'));
$attr = get_request('attr','GET');
2009-06-30 09:29:51 +00:00
# if there are multiple values in this attribute, which one do you want to see?
2009-06-30 11:52:55 +00:00
$value_num = get_request('value_num','GET');
2009-06-30 09:29:51 +00:00
2009-06-30 10:26:08 +00:00
if (! $ldapserver->dnExists($dn))
2009-06-30 11:52:55 +00:00
error(sprintf('%s (%s)',_('No such entry.'),pretty_print_dn($dn)),'error','index.php');
2009-06-30 09:29:51 +00:00
2009-06-30 11:46:44 +00:00
$search = $ldapserver->search(null,$dn,'(objectClass=*)',array($attr),'base',false,$_SESSION[APPCONFIG]->GetValue('deref','view'));
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-06-30 10:26:08 +00:00
header('Content-type: octet-stream');
2009-06-30 09:29:51 +00:00
header("Content-disposition: attachment; filename=$attr");
2009-06-30 10:26:08 +00:00
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Last-Modified: '.gmdate('D, d M Y H:i:s').' GMT');
2009-06-30 11:52:55 +00:00
2009-06-30 10:26:08 +00:00
if ($value_num && is_array($search[$attr][$dn]))
echo $search[$dn][$attr][$value_num];
else
echo $search[$dn][$attr];
2009-06-30 08:07:14 +00:00
?>