}
if ($options['before-days'] && $options['after-days']) {
echo "You cannot use options before-days and after-days at the same time.";
exit(1);
}
if ($options['before-days']) {
$options['begin_date'] = date('Y-m-d H:i:s', time() - $options['before-days'] * DAY_TIMESTAMP);
$options['end_date'] = '';
unset($options['before-days']);
}
if ($options['after-days']) {
$options['begin_date'] = '';
$options['end_date'] = date('Y-m-d H:i:s', time() - $options['after-days'] * DAY_TIMESTAMP);
unset($options['after-days']);
}
if (!Toolbox::canUseLdap() || !countElementsInTable('glpi_authldaps')) {
echo "LDAP extension is not active or no LDAP directory defined";
}
$sql = "SELECT `id`, `name`\n FROM `glpi_authldaps`\n WHERE `is_active` = '1'";
//Get the ldap server's id by his name
if ($options['ldapservers_id'] != NOT_AVAILABLE) {
$sql .= " AND `id` = '" . $options['ldapservers_id'] . "'";
}
$result = $DB->query($sql);
if ($DB->numrows($result) == 0 && $_GET["ldapservers_id"] != NOT_AVAILABLE) {
echo "LDAP Server not found";
} else {
foreach ($DB->request($sql) as $data) {
echo "Processing LDAP Server: " . $data['name'] . ", ID: " . $data['id'] . " \n";
$options['ldapservers_id'] = $data['id'];
import($options);