function page_active_directory()
{
    $acl = new squid_acls();
    $ad = new external_ad_search();
    $DNDUMP = $ad->DNDUMP($_GET["LoadGroupSettings"]);
    $GroupName = $DNDUMP["samaccountname"][0];
    $RULES = $acl->GetRulesFromADGroup($GroupName);
    if ($GLOBALS["VERBOSE"]) {
        echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
    }
    if (is_array($RULES)) {
        while (list($key, $ligne) = each($RULES)) {
            $MAIN_SQUIDRULES[$key] = $ligne;
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "<span style='color:red;font-size:28px'>{$GroupName}:: \$MAIN_SQUIDRULES:" . count($MAIN_SQUIDRULES) . " RULES</span><br>\n";
        }
    }
    $sock = new sockets();
    if ($sock->EnableUfdbGuard() == 1) {
        $MAIN_WEBRULES[0] = "{default}";
        $RULES = $acl->GetWebfilteringRulesFromADGroup($GroupName);
        if ($GLOBALS["VERBOSE"]) {
            echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
        }
        if (is_array($RULES)) {
            while (list($key, $ligne) = each($RULES)) {
                $MAIN_WEBRULES[$key] = $ligne;
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "<span style='color:red;font-size:22px'>{$GroupName}:: \$MAIN_WEBRULES:" . count($MAIN_WEBRULES) . " RULES</span><br>\n";
            }
        }
    }
    if (count($MAIN_SQUIDRULES) > 0) {
        $rules_title = "{rules}";
        if (count($MAIN_SQUIDRULES) < 2) {
            $rules_title = "{rule}";
        }
        while (list($aclid, $aclname) = each($MAIN_SQUIDRULES)) {
            $jsGRP = "Loadjs('squid.acls-rules.php?Addacl-js=yes&ID={$aclid}');";
            $XTRGB[] = "<tr>\n\t\t\t<td style='width:48px'><img src='img/folder-script-database-48.png'></td>\n\t\t\t<td style='font-size:22px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\t\t\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t\t\t</tr>";
        }
        $proxay_acls = "</tr>\n\t\t<tr style='height:70px'>\n\t\t<td valign=middle style='font-size:30px' class=legend>" . count($MAIN_SQUIDRULES) . " {$rules_title} (Proxy):</td>\n\t\t\t\t\t</tr>\n\t\t\t\t\t<tr>\n\t\t\t\t\t<td></td>\n\t\t\t\t\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t\t</tr>";
    }
    if (count($MAIN_WEBRULES) > 0) {
        $XTRGB = array();
        while (list($aclid, $aclname) = each($MAIN_WEBRULES)) {
            $jsGRP = "YahooWin3('1100','dansguardian2.edit.php?ID={$aclid}&t=0','{$aclid} {$aclname}');";
            $XTRGB[] = "<tr>\n\t<td style='width:48px'><img src='img/folder-script-database-48.png'></td>\n\t<td style='font-size:22px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t</tr>";
        }
        $rules_title = "{rules}";
        if (count($MAIN_WEBRULES) < 2) {
            $rules_title = "{rule}";
        }
        $webfilter_acls = "</tr>\n\t<tr style='height:70px'>\n\t<td valign=middle style='font-size:30px' class=legend>" . count($MAIN_WEBRULES) . " {$rules_title} ({webfiltering}):</td>\n\t</tr>\n\t<tr>\n\t<td></td>\n\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t</tr>";
    }
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body("<center style='width:98%' class=form><table style='width:100%'>{$proxay_acls}{$webfilter_acls}</table></center>");
}
function popup()
{
    $users = new usersMenus();
    $ad = new external_ad_search();
    $DNDUMP = $ad->DNDUMP($_GET["DN"]);
    $tpl = new templates();
    if (isset($DNDUMP["description"][0])) {
        $description = $DNDUMP["description"][0];
    }
    $title = $DNDUMP["samaccountname"][0];
    if (isset($DNDUMP["givenname"][0])) {
        $title = "{$DNDUMP["givenname"][0]} {$DNDUMP["sn"][0]}";
    }
    $MAIN_SQUIDRULES = array();
    $MAIN_WEBRULES = array();
    for ($i = 0; $i < $DNDUMP["memberof"]["count"]; $i++) {
        $DN = $DNDUMP["memberof"][$i];
        $XGRP = $ad->DNinfos($DN);
        $GroupName = $XGRP[0]["samaccountname"][0];
        if ($users->SQUID_INSTALLED) {
            $acl = new squid_acls();
            $RULES = $acl->GetRulesFromADGroup($GroupName);
            if ($GLOBALS["VERBOSE"]) {
                echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
            }
            if (is_array($RULES)) {
                while (list($key, $ligne) = each($RULES)) {
                    $MAIN_SQUIDRULES[$key] = $ligne;
                }
                if ($GLOBALS["VERBOSE"]) {
                    echo "<span style='color:red;font-size:22px'>{$GroupName}:: \$MAIN_SQUIDRULES:" . count($MAIN_SQUIDRULES) . " RULES</span><br>\n";
                }
            }
            $sock = new sockets();
            if ($sock->EnableUfdbGuard() == 1) {
                $MAIN_WEBRULES[0] = "{default}";
                $RULES = $acl->GetWebfilteringRulesFromADGroup($GroupName);
                if ($GLOBALS["VERBOSE"]) {
                    echo "<span style='color:red;font-size:22px'>{$GroupName}:: " . count($RULES) . " RULES</span><br>\n";
                }
                if (is_array($RULES)) {
                    while (list($key, $ligne) = each($RULES)) {
                        $MAIN_WEBRULES[$key] = $ligne;
                    }
                    if ($GLOBALS["VERBOSE"]) {
                        echo "<span style='color:red;font-size:22px'>{$GroupName}:: \$MAIN_WEBRULES:" . count($MAIN_WEBRULES) . " RULES</span><br>\n";
                    }
                }
            }
        }
        $jsGRP = "Loadjs('domains.edit.group.php?js=yes&group-id=" . urlencode($DN) . "',true)";
        $XTRG[] = "<tr>\n\t\t\t\t\t<td style='width:16px'><img src='img/wingroup.png'></td>\n\t\t\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\" style='text-decoration:underline'>{$GroupName}</a></td>\n\t\t\t\t</tr>";
    }
    if (count($MAIN_SQUIDRULES) > 0) {
        $rules_title = "{rules}";
        if (count($MAIN_SQUIDRULES) < 2) {
            $rules_title = "{rule}";
        }
        while (list($aclid, $aclname) = each($MAIN_SQUIDRULES)) {
            $jsGRP = "Loadjs('squid.acls-rules.php?Addacl-js=yes&ID={$aclid}');";
            $XTRGB[] = "<tr>\n\t\t\t<td style='width:16px'><img src='img/scripts-16.png'></td>\n\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\" \n\t\t\t\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t\t\t</tr>";
        }
        $proxay_acls = "</tr>\n\t\t<tr style='height:70px'>\n\t\t<td valign=middle style='font-size:26px' class=legend>" . count($MAIN_SQUIDRULES) . " {$rules_title} (Proxy):</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td></td>\n\t\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t\t</tr>";
    }
    if (count($MAIN_WEBRULES) > 0) {
        $XTRGB = array();
        while (list($aclid, $aclname) = each($MAIN_WEBRULES)) {
            $jsGRP = "YahooWin3('1100','dansguardian2.edit.php?ID={$aclid}&t=0','{$aclid} {$aclname}');";
            $XTRGB[] = "<tr>\n\t\t\t<td style='width:16px'><img src='img/scripts-16.png'></td>\n\t\t\t<td style='font-size:16px'><a href=\"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\t\t\tstyle='text-decoration:underline'>{$aclname}</a></td>\n\t\t\t</tr>";
        }
        $rules_title = "{rules}";
        if (count($MAIN_WEBRULES) < 2) {
            $rules_title = "{rule}";
        }
        $webfilter_acls = "</tr>\n\t\t<tr style='height:70px'>\n\t\t<td valign=middle style='font-size:26px' class=legend>" . count($MAIN_WEBRULES) . " {$rules_title} ({webfiltering}):</td>\n\t\t</tr>\n\t\t<tr>\n\t\t<td></td>\n\t\t<td><table style='width:100%'>" . @implode("", $XTRGB) . "</table></td>\n\t\t</tr>";
    }
    $picture_link = "img/impersonate-photo.png";
    $html = "\n\t\t\t\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td style='width:190px;vertical-align:top'>\n\t\t<center style='margin-top:15px'>\n\t\t<img style='border-radius: 50% 50% 50% 50%;\n    \t\tbox-shadow: 0 0 5px silver;height: 180px;margin: 0 32px;width: 180px;' src='{$picture_link}'></a>\n    <center style='font-size: 24px;line-height: 1.2;word-wrap: break-word;margin-top:30px;margin-bottom:30px'>{$title}</center>\n\n    \n    </center>\t\n\t</td>\n\t\t<td style='width:80%;vertical-aglin:top'>\n\t\t\t<table style='width:100%'>\n\t\t\t\t\t</tr>\t\t\t\n\t\t\t\t<tr style='height:70px'>\n\t\t\t\t<td valign=middle style='font-size:26px' class=legend><div>{Contact_Information}:</div><i style='font-size:16px'>{$description}</i></td>\n\t\t\t</tr>\n\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{member}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["givenname"][0]} {$DNDUMP["sn"][0]}</strong></td>\n\t\t\t</tr>\t\t\t\n\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{name}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["name"][0]}</strong></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{account}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["samaccountname"][0]}</strong></td>\n\t\t\t</tr>\n\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{email}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["mail"][0]}</strong></td>\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{telephoneNumber}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["telephonenumber"][0]}</strong></td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td valign=middle style='font-size:18px' class=legend>{mobile}:</td>\n\t\t\t\t<td valign=middle style='font-size:18px'><strong>{$DNDUMP["mobile"][0]}</strong></td>\n\t\t\t</tr>\t\t\t\n\t\t\t\t<tr style='height:70px'>\n\t\t\t\t<td valign=middle style='font-size:26px' class=legend>{$DNDUMP["memberof"]["count"]} {groups}:</td>\n\t\t\t</tr>\t\t\t\n\t\t\t<tr>\n\t\t\t\t<td></td>\n\t\t\t\t<td><table style='width:100%'>" . @implode("", $XTRG) . "</table></td>\n\t\t\t</tr>\n\t\t\t{$proxay_acls}\n\t\t\t{$webfilter_acls}\n\t\t\t</table>\n\t\t</td>\n\t</tr>\n\t</table>\n\t<p>&nbsp;</p>\n\t</div>\n\t\t\t\n\t";
    echo $tpl->_ENGINE_parse_body($html);
}