phpldapadmin/htdocs/export_form.php

214 lines
6.1 KiB
PHP
Raw Permalink Normal View History

2009-06-30 09:22:30 +00:00
<?php
/**
* Export entries from the LDAP server.
*
2009-06-30 09:29:51 +00:00
* @package phpLDAPadmin
* @subpackage Page
2009-06-30 09:29:51 +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
$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
$available_formats = array(
2009-06-30 10:26:08 +00:00
'mac' => 'Macintosh',
'unix' => 'UNIX (Linux, BSD)',
2009-06-30 09:22:30 +00:00
'win' => 'Windows'
);
$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
);
$request['page'] = new PageRender($app['server']->getIndex(),get_request('template','REQUEST',false,'none'));
$request['page']->drawTitle(sprintf('<b>%s</b>',_('Export')));
2009-08-22 11:30:50 +00:00
printf('<script type="text/javascript" language="javascript" src="%sdnChooserPopup.js"></script>',JSDIR);
printf('<script type="text/javascript" language="javascript" src="%sform_field_toggle_enable.js"></script>',JSDIR);
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" />';
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-08-22 11:30:50 +00:00
printf('<tr><td>%s</td><td>%s</td></tr>',_('Server'),$app['server']->getName());
2009-06-30 10:26:08 +00:00
echo '<tr>';
printf('<td style="white-space:nowrap">%s</td>',_('Base DN'));
echo '<td><span style="white-space: nowrap;">';
printf('<input type="text" name="dn" id="dn" style="width:230px" value="%s" />&nbsp;',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 />',
htmlspecialchars($id),$id,($id == $request['scope']) ? 'checked="true"' : '',
htmlspecialchars($id),$desc);
2009-06-30 10:26:08 +00:00
echo '</td>';
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>',
_('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>',
_('Show Attributtes'),htmlspecialchars($request['attr']));
2009-06-30 10:26:08 +00:00
printf('<tr><td>&nbsp;</td><td><input type="checkbox" name="sys_attr" id="sys_attr" %s/> <label for="sys_attr">%s</label></td></tr>',
$request['sys_attr'] ? 'checked="true" ' : '',_('Include system attributes'));
2009-06-30 10:26:08 +00:00
2009-08-22 11:30:50 +00:00
printf('<tr><td>&nbsp;</td><td><input type="checkbox" id="save_as_file" name="save_as_file" onclick="export_field_toggle(this)" /> <label for="save_as_file">%s</label></td></tr>',
2009-06-30 10:26:08 +00:00
_('Save as file'));
printf('<tr><td>&nbsp;</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%">';
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'));
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 />',
htmlspecialchars($exporter['type']),$exporter['type']);
2009-06-30 10:26:08 +00:00
}
echo '</fieldset>';
echo '</td>';
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 />',
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-06-30 10:26:08 +00:00
echo '</tr>';
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-06-30 10:26:08 +00:00
echo '</table>';
echo '</form>';
echo '</center>';
2009-06-30 09:22:30 +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() {
if (is_browser('win'))
2009-06-30 10:26:08 +00:00
return 'win';
elseif (is_browser('unix'))
2009-06-30 10:26:08 +00:00
return 'unix';
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
/**
* 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']))
2009-08-19 03:39:37 +00:00
return strtolower($_SERVER['HTTP_USER_AGENT']);
else
2009-08-19 03:39:37 +00:00
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
?>