예제 #1
0
function search()
{
    $t = $_GET["t"];
    $EnableOpenLDAP = intval(@file_get_contents("/etc/artica-postfix/settings/Daemons/EnableOpenLDAP"));
    $_SESSION["SEARCH_GROUPS_MEMORY"] = $_GET["search"];
    $stringtofind = url_decode_special_tool($_GET["search"]);
    if (preg_match("#(.+?)\\s+\\(#", $stringtofind, $re)) {
        $stringtofind = trim($re[1]);
    }
    $stringtofind = "{$stringtofind}*";
    $stringtofind = str_replace("**", "*", $stringtofind);
    $ldap = new clladp();
    $tpl = new templates();
    $IsKerbAuth = $ldap->IsKerbAuth();
    if ($IsKerbAuth == 0) {
        if ($EnableOpenLDAP == 1) {
            $MAIN_HASH = $ldap->GroupsSearch($stringtofind, 50);
        }
    } else {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $MAIN_HASH = $ad->GroupsSearch(null, $stringtofind, 50);
    }
    $TABLE[] = "<table style='width:100%'>";
    $colortr = null;
    if (is_array($MAIN_HASH)) {
        while (list($GroupDN, $displayname) = each($MAIN_HASH)) {
            if ($colortr == "f0f9ec") {
                $colortr = "FFFFFF";
            } else {
                $colortr = "f0f9ec";
            }
            if (strpos($GroupDN, "dc=pureftpd,dc=organizations") > 0) {
                continue;
            }
            if ($displayname == null) {
                continue;
            }
            if ($IsKerbAuth == 1) {
                $CountofUsers = $ad->CountDeUsersByGroupDN($GroupDN);
            } else {
                $CountofUsers = $ldap->CountDeUsersByGroupDN($GroupDN);
            }
            $TABLE[] = "<tr style='height:60px;background-color:{$colortr}'>";
            if ($IsKerbAuth == 1) {
                $jsGRP = "Loadjs('domains.edit.group.php?js=yes&group-id=" . urlencode($GroupDN) . "',true)";
            } else {
                $GidNumberGroupDN = $ldap->GidNumberGroupDN($GroupDN);
                $jsGRP = "Loadjs('domains.edit.group.php?js=yes&group-id={$GidNumberGroupDN}',true)";
            }
            $picture_link = "img/group-48.png";
            $linkuser = "******"javascript:blur();\" OnClick=\"javascript:{$jsGRP}\"\n\t\t\tstyle='text-decoration:underline'>";
            $TABLE[] = "<td style='width:48px;'>";
            $TABLE[] = "<img src='{$picture_link}' style='border-radius: 50% 50% 50% 50%; box-shadow: 0 0 5px silver;height: 48px;margin: 0 32px;width: 48px;'>";
            $TABLE[] = "</td>";
            $TABLE[] = "<td style='width:300px;padding-left:5px'>";
            $TABLE[] = "<span style='font-size:18px'>{$linkuser}{$displayname}</a></span>";
            $TABLE[] = "</td>";
            $TABLE[] = "<td style='width:300px;padding-left:5px'>";
            $TABLE[] = "<span style='font-size:18px'>{$CountofUsers} {members}</span>";
            $TABLE[] = "</td>";
            $TABLE[] = "<td>";
            $TABLE[] = "<span style='font-size:18px;padding-left:5px;width:300px;'>" . @implode("", $telephonenumber) . "</span>";
            $TABLE[] = "</td>";
            $TABLE[] = "<td>";
            $TABLE[] = "<span style='font-size:18px;padding-left:5px'>{$GroupsTableau}</span>";
            $TABLE[] = "</td>";
            $TABLE[] = "</tr>";
        }
    }
    $TABLE[] = "</table>";
    $TABLE[] = "<script>";
    $TABLE[] = "document.getElementById('title-{$t}').innerHTML='{$stringtofind}';";
    $TABLE[] = "</script>";
    echo $tpl->_ENGINE_parse_body(@implode("", $TABLE));
}
예제 #2
0
function popup_search()
{
    $icon = "win7groups-32.png";
    $ad = new external_ad_search();
    if ($_POST["query"] == null) {
        $_POST["query"] = "*";
    }
    if (strpos(" {$_POST["query"]}", "*") == 0) {
        $_POST["query"] = "*{$_POST["query"]}*";
    }
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $_POST["query"] = str_replace("**", "*", $_POST["query"]);
    $Array = $ad->flexRTGroups($_POST["query"], $_POST["rp"]);
    if ($ad->error != null) {
        json_error_show($ad->error, 1);
    }
    if (count($Array) == 0) {
        json_error_show("No item", 1);
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = count($Array);
    $data['rows'] = array();
    while (list($dn, $itemname) = each($Array)) {
        $GroupxSourceName = $itemname;
        $GroupxName = $itemname;
        $GroupxName = replace_accents($GroupxName);
        $GroupxName = str_replace("'", "`", $itemname);
        $addtitile = null;
        $select = null;
        $dn_enc = base64_encode($dn);
        $DN_base64 = base64_encode($dn);
        $itemnameenc = base64_encode($itemname);
        $CountDeUsers = $ad->CountDeUsersByGroupDN($dn);
        $link = null;
        $js = "EditField{$_GET["t"]}('{$DN_base64}','{$GroupxSourceName}');";
        $image = imgsimple($icon, null, $js);
        $select = imgsimple("arrow-right-32.png", null, $js);
        if ($CountDeUsers > 0) {
            $link = "<a href=\"javascript:Loadjs('browse-ad-users-dn.php?DN={$DN_base64}')\"\n\t\t\tstyle='text-decoration:underline'>";
        }
        $md5 = md5($dn);
        $data['rows'][] = array('id' => $md5, 'cell' => array("<center>{$image}</center>", "<span style='font-size:20px;'>{$link}{$GroupxName}</a></span>", "<center style='font-size:20px;'>{$CountDeUsers}</center>", "<center>{$select}</center>"));
    }
    echo json_encode($data);
}