LoadSettings();
$max_execution_time = ini_get('max_execution_time');
$GLOBALS["SESSIONS"] = unserialize(@file_get_contents("/etc/squid3/" . basename(__FILE__) . ".cache"));
WLOG("[START]: Starting New process with KerbAuthInfos:" . count($GLOBALS["KerbAuthInfos"]) . " Parameters debug = {$GLOBALS["DEBUG_GROUPS"]} AdStatsGroupMethod={$GLOBALS["AdStatsGroupMethod"]}");
ConnectToLDAP();
$external_acl_squid_ldap = new external_acl_squid_ldap();
if ($argv[1] == "--groups") {
    $GLOBALS["VERBOSE"] = true;
    $GLOBALS["DEBUG_GROUPS"] = true;
    $GROUPZ = $external_acl_squid_ldap->GetGroupsFromMember($argv[2]);
    echo "********************* GROUPS ***********************\n";
    echo count($GROUPZ) . "\n\n";
    print_r($GROUPZ);
    echo "\n\n************************************************\n\n\n";
    echo "********************* RECURSIVE ***********************\n";
    $external_acl_squid_ldap->ADLdap_getgroups($argv[2]);
    $infos = $external_acl_squid_ldap->ADLdap_userinfos($argv[2]);
    echo "********************* INFOS ***********************\n";
    echo "Organization: " . $external_acl_squid_ldap->GetUserOU($argv[2]) . "\n";
    die;
}
while (!feof(STDIN)) {
    $content = trim(fgets(STDIN));
    if ($content != null) {
        $AS_TAG = false;
        if ($GLOBALS["DEBUG_GROUPS"] > 0) {
            WLOG("receive content...\"{$content}\"");
        }
        $array = explode(" ", $content);
        $member = trim($array[0]);
        $member = str_replace("%20", " ", $member);
function parseTemplate_if_in_ADGroup($adgroup, $client_username)
{
    include_once dirname(__FILE__) . "/ressources/class.external_acl_squid_ldap.inc";
    if (!isset($_SESSION["GROUPES_IN_AD"])) {
        $ad = new external_acl_squid_ldap();
        $groupes = $ad->ADLdap_getgroups($client_username);
        while (list($GroupName, $none) = each($groupes)) {
            $GROUPES_IN_AD[trim(strtolower($GroupName))] = true;
        }
        $_SESSION["GROUPES_IN_AD"] = $GROUPES_IN_AD;
    } else {
        $GROUPES_IN_AD = $_SESSION["GROUPES_IN_AD"];
    }
    if (strpos($adgroup, ",") > 0) {
        $QueriesGroups = explode(",", $adgroup);
    } else {
        $QueriesGroups[] = $adgroup;
    }
    while (list($none, $GroupName) = each($QueriesGroups)) {
        $GROUPES_TO_AD[trim(strtolower($GroupName))] = true;
    }
    while (list($GroupName, $none) = each($GROUPES_TO_AD)) {
        if (isset($GROUPES_IN_AD[$GroupName])) {
            return true;
        }
    }
}