2009-06-30 09:22:30 +00:00
|
|
|
<?php
|
2009-07-01 06:09:17 +00:00
|
|
|
// $Header$
|
2009-06-30 09:22:30 +00:00
|
|
|
|
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Export entries from the LDAP server.
|
|
|
|
*
|
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
|
|
|
*/
|
|
|
|
|
2009-06-30 09:29:51 +00:00
|
|
|
require './common.php';
|
|
|
|
require LIBDIR.'export_functions.php';
|
2009-06-30 09:22:30 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request = array();
|
|
|
|
$request['dn'] = get_request('dn','GET');
|
|
|
|
$request['format'] = get_request('format','GET',false,get_line_end_format());
|
|
|
|
$request['scope'] = get_request('scope','GET',false,'base');
|
|
|
|
$request['exporter_id'] = get_request('exporter_id','GET',false,'LDIF');
|
|
|
|
$request['filter'] = get_request('filter','GET',false,'(objectClass=*)');
|
|
|
|
$request['attr'] = get_request('attributes','GET',false,'*');
|
|
|
|
$request['sys_attr'] = get_request('sys_attr','GET') ? true: false;
|
2009-06-30 10:26:08 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$available_formats = array(
|
2009-06-30 10:26:08 +00:00
|
|
|
'mac' => 'Macintosh',
|
2009-07-01 06:09:17 +00:00
|
|
|
'unix' => 'UNIX (Linux, BSD)',
|
2009-06-30 09:22:30 +00:00
|
|
|
'win' => 'Windows'
|
|
|
|
);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$available_scopes = array(
|
2009-06-30 10:26:08 +00:00
|
|
|
'base' => _('Base (base dn only)'),
|
|
|
|
'one' => _('One (one level beneath base)'),
|
|
|
|
'sub' => _('Sub (entire subtree)')
|
2009-06-30 09:22:30 +00:00
|
|
|
);
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
|
|
|
|
$request['page']->drawTitle(sprintf('<b>%s</b>',_('Export')));
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<br />';
|
|
|
|
echo '<center>';
|
2009-06-30 10:46:00 +00:00
|
|
|
echo '<form name="export_form" action="cmd.php" method="post">';
|
|
|
|
echo '<input type="hidden" name="cmd" value="export" />';
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<input type="hidden" name="server_id" value="%s" />',$app['server']->getIndex());
|
|
|
|
|
2009-06-30 11:51:50 +00:00
|
|
|
echo '<table class="forminput">';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<tr>';
|
|
|
|
echo '<td>';
|
|
|
|
|
|
|
|
echo '<fieldset>';
|
|
|
|
printf('<legend>%s</legend>',_('Export'));
|
|
|
|
|
|
|
|
echo '<table>';
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<tr><td>%s</td><td>%s</td></tr>',_('Server'),server_select_list($app['server']->getIndex()));
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
echo '<tr>';
|
|
|
|
printf('<td style="white-space:nowrap">%s</td>',_('Base DN'));
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '<td><span style="white-space: nowrap;">';
|
|
|
|
printf('<input type="text" name="dn" id="dn" style="width:230px" value="%s" /> ',htmlspecialchars($request['dn']));
|
2009-06-30 10:26:08 +00:00
|
|
|
draw_chooser_link('export_form.dn');
|
2009-06-30 10:41:18 +00:00
|
|
|
echo '</span></td>';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '</tr>';
|
|
|
|
|
|
|
|
echo '<tr>';
|
|
|
|
printf('<td><span style="white-space: nowrap">%s</span></td>',_('Search Scope'));
|
|
|
|
|
|
|
|
echo '<td>';
|
|
|
|
|
|
|
|
foreach ($available_scopes as $id => $desc)
|
|
|
|
printf('<input type="radio" name="scope" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
|
2009-07-01 06:09:17 +00:00
|
|
|
htmlspecialchars($id),$id,($id == $request['scope']) ? 'checked="true"' : '',
|
|
|
|
htmlspecialchars($id),$desc);
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
echo '</td>';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '</tr>';
|
|
|
|
|
|
|
|
printf('<tr><td>%s</td><td><input type="text" name="filter" style="width:300px" value="%s" /></td></tr>',
|
2009-07-01 06:09:17 +00:00
|
|
|
_('Search Filter'),htmlspecialchars($request['filter']));
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
printf('<tr><td>%s</td><td><input type="text" name="attributes" style="width:300px" value="%s" /></td></tr>',
|
2009-07-01 06:09:17 +00:00
|
|
|
_('Show Attributtes'),htmlspecialchars($request['attr']));
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
printf('<tr><td> </td><td><input type="checkbox" name="sys_attr" id="sys_attr" %s/> <label for="sys_attr">%s</label></td></tr>',
|
2009-07-01 06:09:17 +00:00
|
|
|
$request['sys_attr'] ? 'checked="true" ' : '',_('Include system attributes'));
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
printf('<tr><td> </td><td><input type="checkbox" id="save_as_file" name="save_as_file" onclick="toggle_disable_field_saveas(this)" /> <label for="save_as_file">%s</label></td></tr>',
|
|
|
|
_('Save as file'));
|
|
|
|
|
|
|
|
printf('<tr><td> </td><td><input type="checkbox" id="compress" name="compress" disabled /> <label for="compress">%s</label></td></tr>',
|
|
|
|
_('Compress'));
|
|
|
|
|
|
|
|
echo '</table>';
|
|
|
|
echo '</fieldset>';
|
|
|
|
echo '</td>';
|
|
|
|
echo '</tr>';
|
|
|
|
echo '<tr>';
|
|
|
|
echo '<td>';
|
|
|
|
|
|
|
|
echo '<table style="width: 100%">';
|
2009-07-01 06:09:17 +00:00
|
|
|
echo '<tr>';
|
|
|
|
|
|
|
|
echo '<td style="width: 50%">';
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<fieldset style="height: 100px">';
|
|
|
|
|
|
|
|
printf('<legend>%s</legend>',_('Export format'));
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
foreach (Exporter::types() as $index => $exporter) {
|
|
|
|
printf('<input type="radio" name="exporter_id" id="exporter_id_%s" value="%s"%s/>',
|
|
|
|
htmlspecialchars($exporter['type']),htmlspecialchars($exporter['type']),($exporter['type'] === $request['exporter_id']) ? ' checked="true"' : '');
|
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
printf('<label for="%s">%s</label><br />',
|
2009-07-01 06:09:17 +00:00
|
|
|
htmlspecialchars($exporter['type']),$exporter['type']);
|
2009-06-30 10:26:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
echo '</fieldset>';
|
|
|
|
echo '</td>';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '<td style="width: 50%">';
|
|
|
|
echo '<fieldset style="height: 100px">';
|
|
|
|
|
|
|
|
printf('<legend>%s</legend>',_('Line ends'));
|
|
|
|
foreach ($available_formats as $id => $desc)
|
|
|
|
printf('<input type="radio" name="format" value="%s" id="%s"%s /><label for="%s">%s</label><br />',
|
2009-07-01 06:09:17 +00:00
|
|
|
htmlspecialchars($id),htmlspecialchars($id),($request['format']==$id) ? ' checked="true"' : '',
|
|
|
|
htmlspecialchars($id),$desc);
|
2009-06-30 10:26:08 +00:00
|
|
|
|
|
|
|
echo '</fieldset>';
|
|
|
|
echo '</td></tr>';
|
|
|
|
echo '</table>';
|
|
|
|
echo '</td>';
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '</tr>';
|
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
printf('<tr><td colspan="2"><center><input type="submit" name="target" value="%s" /></center></td></tr>',
|
2009-06-30 10:26:08 +00:00
|
|
|
htmlspecialchars(_('Proceed >>')));
|
2009-07-01 06:09:17 +00:00
|
|
|
|
2009-06-30 10:26:08 +00:00
|
|
|
echo '</table>';
|
|
|
|
|
|
|
|
echo '</form>';
|
|
|
|
echo '</center>';
|
2009-06-30 09:22:30 +00:00
|
|
|
|
|
|
|
/**
|
2009-07-01 06:09:17 +00:00
|
|
|
* Helper function for fetching the line end format.
|
|
|
|
*
|
2009-06-30 09:22:30 +00:00
|
|
|
* @return String 'win', 'unix', or 'mac' based on the user's browser..
|
|
|
|
*/
|
2009-06-30 10:26:08 +00:00
|
|
|
function get_line_end_format() {
|
2009-07-01 06:09:17 +00:00
|
|
|
if (is_browser('win'))
|
2009-06-30 10:26:08 +00:00
|
|
|
return 'win';
|
2009-07-01 06:09:17 +00:00
|
|
|
elseif (is_browser('unix'))
|
2009-06-30 10:26:08 +00:00
|
|
|
return 'unix';
|
2009-07-01 06:09:17 +00:00
|
|
|
elseif (is_browser('mac'))
|
2009-06-30 10:26:08 +00:00
|
|
|
return 'mac';
|
|
|
|
else
|
|
|
|
return 'unix';
|
2009-06-30 09:22:30 +00:00
|
|
|
}
|
2009-06-30 10:26:08 +00:00
|
|
|
|
2009-07-01 06:09:17 +00:00
|
|
|
/**
|
|
|
|
* Gets the USER_AGENT string from the $_SERVER array, all in lower case in
|
|
|
|
* an E_NOTICE safe manner.
|
|
|
|
*
|
|
|
|
* @return string|false The user agent string as reported by the browser.
|
|
|
|
*/
|
|
|
|
function get_user_agent_string() {
|
|
|
|
if (isset($_SERVER['HTTP_USER_AGENT']))
|
|
|
|
$return = strtolower($_SERVER['HTTP_USER_AGENT']);
|
|
|
|
else
|
|
|
|
$return = '';
|
|
|
|
|
|
|
|
if (DEBUG_ENABLED)
|
|
|
|
debug_log('Entered with (), Returning (%s)',1,__FILE__,__LINE__,__METHOD__,$return);
|
|
|
|
|
|
|
|
return $return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Determine the OS for the browser
|
|
|
|
*/
|
|
|
|
function is_browser($type) {
|
|
|
|
$agents = array();
|
|
|
|
|
|
|
|
$agents['unix'] = array(
|
|
|
|
'sunos','sunos 4','sunos 5',
|
|
|
|
'i86',
|
|
|
|
'irix','irix 5','irix 6','irix6',
|
|
|
|
'hp-ux','09.','10.',
|
|
|
|
'aix','aix 1','aix 2','aix 3','aix 4',
|
|
|
|
'inux',
|
|
|
|
'sco',
|
|
|
|
'unix_sv','unix_system_v','ncr','reliant','dec','osf1',
|
|
|
|
'dec_alpha','alphaserver','ultrix','alphastation',
|
|
|
|
'sinix',
|
|
|
|
'freebsd','bsd',
|
|
|
|
'x11','vax','openvms'
|
|
|
|
);
|
|
|
|
|
|
|
|
$agents['win'] = array(
|
|
|
|
'win','win95','windows 95',
|
|
|
|
'win16','windows 3.1','windows 16-bit','windows','win31','win16','winme',
|
|
|
|
'win2k','winxp',
|
|
|
|
'win98','windows 98','win9x',
|
|
|
|
'winnt','windows nt','win32',
|
|
|
|
'32bit'
|
|
|
|
);
|
|
|
|
|
|
|
|
$agents['mac'] = array(
|
|
|
|
'mac','68000','ppc','powerpc'
|
|
|
|
);
|
|
|
|
|
|
|
|
if (isset($agents[$type]))
|
|
|
|
return in_array(get_user_agent_string(),$agents[$type]);
|
|
|
|
else
|
|
|
|
return false;
|
|
|
|
}
|
2009-06-30 10:26:08 +00:00
|
|
|
?>
|
|
|
|
<script type="text/javascript" language="javascript">
|
|
|
|
<!--
|
2009-07-01 06:09:17 +00:00
|
|
|
function toggle_disable_field_saveas(id) {
|
|
|
|
if (id.checked) {
|
|
|
|
id.form.compress.disabled = false;
|
|
|
|
} else {
|
|
|
|
id.form.compress.disabled = true;
|
|
|
|
id.form.compress.checked = false;
|
|
|
|
}
|
|
|
|
}
|
2009-06-30 10:26:08 +00:00
|
|
|
-->
|
|
|
|
</script>
|