function ufdbguard_checks($id)
{
    LoadSettings();
    if ($GLOBALS["VERBOSE"]) {
        $GLOBALS["output"] = true;
        echo "OPEN: /etc/squid3/ufdb.groups.{$id}.db\n";
    }
    if (!is_file("/etc/squid3/ufdb.groups.{$id}.db")) {
        if ($GLOBALS["output"]) {
            echo "Cannot perform this operation\nYou have to create correctly a Web filtering rule\nIncluding blacklists and whitelists\nAnd compile your Web filtering rules in order to dump groups\n";
        }
        return null;
    }
    $arrayGROUPS = unserialize(@file_get_contents("/etc/squid3/ufdb.groups.{$id}.db"));
    $FINAL = array();
    $Hash = array();
    if ($GLOBALS["VERBOSE"]) {
        echo "DUMP: ARRAY ***********************\n";
    }
    if ($GLOBALS["VERBOSE"]) {
        print_r($arrayGROUPS);
    }
    if ($GLOBALS["VERBOSE"]) {
        echo "***********************************\n";
    }
    if (isset($arrayGROUPS["EXT-LDAP"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Found:EXT-LDAP\n";
        }
        $extn_ldap = new ldap_extern();
        while (list($index, $DNS) = each($arrayGROUPS["EXT-LDAP"])) {
            if ($GLOBALS["VERBOSE"]) {
                echo "DN:{$DNS}\n";
            }
            $rr = $extn_ldap->HashUsersFromGroupDN($DNS);
            if ($GLOBALS["output"]) {
                echo "{$DNS} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                $b = trim($b);
                if ($b == null) {
                    continue;
                }
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
            while (list($a, $b) = each($MemberArray)) {
                $FINAL[] = $a;
            }
        }
    }
    if (isset($arrayGROUPS["EXTLDAP"])) {
        while (list($index, $CONFS) = each($arrayGROUPS["EXTLDAP"])) {
            $rr = external_ldap_members($CONFS["DN"], $CONFS["CONF"]);
            if ($GLOBALS["output"]) {
                echo "{$CONFS["DN"]} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
        }
        while (list($a, $b) = each($MemberArray)) {
            $FINAL[] = $a;
        }
    }
    if (isset($arrayGROUPS["AD"])) {
        while (list($index, $DNenc) = each($arrayGROUPS["AD"])) {
            $DN = base64_decode($DNenc);
            if ($GLOBALS["output"]) {
                echo "Loading Active Directory groups...\n";
            }
            if ($GLOBALS["output"]) {
                echo "Branch {$DN}\n";
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN}\n";
            }
            $ldapExt = new external_acl_squid_ldap();
            $members = $ldapExt->AdLDAP_MembersFromGroup($DN);
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN} -> " . count($members) . "\n";
            }
            while (list($a, $b) = each($members)) {
                $Hash[$b] = $b;
            }
        }
        while (list($a, $b) = each($Hash)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "USER= {$b}\n";
            }
            $FINAL[] = $b;
        }
    }
    if (isset($arrayGROUPS["LDAP"])) {
        while (list($index, $gpid) = each($arrayGROUPS["LDAP"])) {
            $Hash = HashUsersFromGPID($gpid);
            if (count($Hash) == 0) {
                WLOG("[QUERY]: ufdbguard_checks({$id}) GPID:{$gpid} store no user...");
                continue;
            }
            while (list($a, $b) = each($Hash)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "USER= {$b}\n";
                }
                $FINAL[] = $b;
            }
        }
    }
    if ($GLOBALS["output"]) {
        echo "\nResults\n**********************************\n# # # # # # # # # # # # # # # # # # # # # #\n" . count($FINAL) . " item(s)\n# # # # # # # # # # # # # # # # # # # # # #\n";
    }
    if (count($FINAL) == 0) {
        WLOG("[QUERY]: ufdbguard_checks({$id}) no user...");
        return;
    }
    while (list($a, $Member) = each($FINAL)) {
        $Member = trim($Member);
        if ($Member == null) {
            continue;
        }
        $Member = str_replace(" ", "%20", $Member);
        $FINAL2[] = $Member;
    }
    echo @implode($FINAL2, "\n") . "\n";
}
function ufdbguard_checks($id)
{
    LoadSettings();
    if ($GLOBALS["VERBOSE"]) {
        $GLOBALS["output"] = true;
        echo "OPEN: /etc/squid3/ufdb.groups.{$id}.db\n";
    }
    $arrayGROUPS = unserialize(@file_get_contents("/etc/squid3/ufdb.groups.{$id}.db"));
    $FINAL = array();
    $Hash = array();
    if (isset($arrayGROUPS["EXT-LDAP"])) {
        if ($GLOBALS["VERBOSE"]) {
            echo "Found:EXT-LDAP\n";
        }
        $extn_ldap = new ldap_extern();
        while (list($index, $DNS) = each($arrayGROUPS["EXT-LDAP"])) {
            if ($GLOBALS["VERBOSE"]) {
                echo "DN:{$DNS}\n";
            }
            $rr = $extn_ldap->HashUsersFromGroupDN($DNS);
            if ($GLOBALS["output"]) {
                echo "{$DNS} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                $b = trim($b);
                if ($b == null) {
                    continue;
                }
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
            while (list($a, $b) = each($MemberArray)) {
                $FINAL[] = $a;
            }
        }
    }
    if (isset($arrayGROUPS["EXTLDAP"])) {
        while (list($index, $CONFS) = each($arrayGROUPS["EXTLDAP"])) {
            $rr = external_ldap_members($CONFS["DN"], $CONFS["CONF"]);
            if ($GLOBALS["output"]) {
                echo "{$CONFS["DN"]} return " . count($rr) . " users\n";
            }
            while (list($a, $b) = each($rr)) {
                echo "USER= {$b}\n";
                $MemberArray[$a] = $a;
            }
        }
        while (list($a, $b) = each($MemberArray)) {
            $FINAL[] = $a;
        }
    }
    if (isset($arrayGROUPS["AD"])) {
        while (list($index, $DNenc) = each($arrayGROUPS["AD"])) {
            $DN = base64_decode($DNenc);
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN}\n";
            }
            $ldapExt = new external_acl_squid_ldap();
            $members = $ldapExt->AdLDAP_MembersFromGroup($DN);
            if ($GLOBALS["VERBOSE"]) {
                echo "DN, {$DN} -> " . count($members) . "\n";
            }
            while (list($a, $b) = each($members)) {
                $Hash[$b] = $b;
            }
        }
        while (list($a, $b) = each($Hash)) {
            if ($GLOBALS["VERBOSE"]) {
                echo "USER= {$b}\n";
            }
            $FINAL[] = $b;
        }
    }
    if (isset($arrayGROUPS["LDAP"])) {
        while (list($index, $gpid) = each($arrayGROUPS["LDAP"])) {
            $Hash = HashUsersFromGPID($gpid);
            if (count($Hash) == 0) {
                WLOG("[QUERY]: ufdbguard_checks({$id}) GPID:{$gpid} store no user...");
                continue;
            }
            while (list($a, $b) = each($Hash)) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "USER= {$b}\n";
                }
                $FINAL[] = $b;
            }
        }
    }
    if ($GLOBALS["output"]) {
        echo "\nResults\n**********************************\n# # # # # # # # # # # # # # # # # # # # # #\n" . count($FINAL) . " item(s)\n# # # # # # # # # # # # # # # # # # # # # #\n";
    }
    if (count($FINAL) == 0) {
        WLOG("[QUERY]: ufdbguard_checks({$id}) no user...");
        return;
    }
    while (list($a, $Member) = each($FINAL)) {
        $Member = trim($Member);
        if ($Member == null) {
            continue;
        }
        $Member = str_replace(" ", "%20", $Member);
        $FINAL2[] = $Member;
    }
    echo @implode($FINAL2, "\n") . "\n";
}