<?php

include_once 'ressources/class.templates.inc';
include_once 'ressources/class.ldap.inc';
include_once 'ressources/class.users.menus.inc';
include_once 'ressources/class.mysql.inc';
include_once 'ressources/class.os.system.inc';
include_once 'ressources/class.activedirectory.inc';
include_once dirname(__FILE__) . '/framework/frame.class.inc';
include_once dirname(__FILE__) . '/framework/class.unix.inc';
if (posix_getuid() != 0) {
    die("Cannot be used in web server mode\n\n");
}
if (preg_match("#--verbose#", implode(" ", $argv))) {
    $GLOBALS["VERBOSE"] = true;
}
if (preg_match("#--output#", implode(" ", $argv))) {
    $GLOBALS["output"] = true;
}
cpulimit();
$ou = $argv[1];
$ad = new wad($ou);
$ad->Perform_import();
function main_import()
{
    $ad = new wad($_GET["ou"]);
    if (isset($_GET["dn_ou"])) {
        $ad->dn_ou = $_GET["dn_ou"];
    }
    if (isset($_GET["target_group"])) {
        $ad->target_group = $_GET["target_group"];
    }
    $ad->SaveToLdap();
    $ad->Perform_import();
    $html = "\n\t\t<input type='hidden' id='dn_ou' value='{$ad->dn_ou}'>\n\t\t<input type='hidden' id='target_group' value='{$ad->target_group}'>\n\t\t<br>\n\t\t<center>\n\t\t<input type='button' style='margin:10px' value='&laquo;&nbsp;{restart_importation}&nbsp;&raquo;' OnClick=\"javascript:AddStep2('{$_GET["ou"]}');\">\n\t\t<br>\n\t\t" . RoundedLightGreen($ad->ldap_error) . "\n\t\t<br>\n\t\t\n\t\t</center>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}