function FindComputerByIP()
{
    if ($_GET["SelectDansGuardianExceptionipList"] == '*') {
        $_GET["SelectDansGuardianExceptionipList"] = null;
    }
    if ($_GET["SelectDansGuardianExceptionipList"] == null) {
        $tofind = "*";
    } else {
        $tofind = "{$_GET["SelectDansGuardianExceptionipList"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    writelogs($filter_search, __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 10);
    $html = "<table style='width:250px' class=table_form>";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        if (trim($ip) == null) {
            continue;
        }
        $js = "AddDansGuardianExceptionipList('{$ip}');";
        $html = $html . "<tr " . CellRollOver($js, "{add}") . ">\n\t\t<td width=1%><img src='img/base.gif'></td>\n\t\t<td nowrap><strong>{$hash[$i]["uid"][0]}</strong></td>\n\t\t<td ><strong>{$ip}</strong></td>\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $html = "<center><div style='height:300px;overflow:auto'>{$html}</div></center>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
Esempio n. 2
0
function find_member()
{
    $tofind = $_GET["find-member"];
    if ($_SESSION["uid"] == -100) {
        $ou = $_GET["ou"];
    } else {
        $ou = $_SESSION["ou"];
    }
    $ldap = new clladp();
    if (is_base64_encoded($ou)) {
        $ou = base64_decode($ou);
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $tofind = str_replace('***', '*', $tofind);
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind}) ))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber");
    $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs, 20);
    $users = new user();
    $number = $hash["count"];
    for ($i = 0; $i < $number; $i++) {
        $user = $hash[$i];
        $html = $html . formatUser($user);
    }
    return $html;
}
function export_to_zarafa($uid)
{
    $f[] = "First Name,Middle Name,Last Name,Title,Suffix,Initials,Web Page,Gender,Birthday,Anniversary,Location,Language,Internet Free Busy,Notes,E-mail Address,E-mail 2 Address,E-mail 3 Address,Primary Phone,Home Phone,Home Phone 2,Mobile Phone,Pager,Home Fax,Home Address,Home Street,Home Street 2,Home Street 3,Home Address PO Box,Home City,Home State,Home Postal Code,Home Country,Spouse,Children,Manager's Name,Assistant's Name,Referred By,Company Main Phone,Business Phone,Business Phone 2,Business Fax,Assistant's Phone,Company,Job Title,Department,Office Location,Organizational ID Number,Profession,Account,Business Address,Business Street,Business Street 2,Business Street 3,Business Address PO Box,Business City,Business State,Business Postal Code,Business Country,Other Phone,Other Fax,Other Address,Other Street,Other Street 2,Other Street 3,Other Address PO Box,Other City,Other State,Other Postal Code,Other Country,Callback,Car Phone,ISDN,Radio Phone,TTY/TDD Phone,Telex,User 1,User 2,User 3,User 4,Keywords,Mileage,Hobby,Billing Information,Directory Server,Sensitivity,Priority,Private,Categories";
    $ldap = new clladp();
    $ct = new user($uid);
    $dn = "ou={$uid},ou=People,dc={$ct->ou},dc=NAB,{$ldap->suffix}";
    $filter = "(objectClass=inetOrgPerson)";
    $attrs = array();
    $hash = $ldap->Ldap_search($dn, $filter, array("employeeNumber"));
    if ($GLOBALS["VERBOSE"]) {
        echo "[{$uid}]: Exporting {$hash["count"]} user(s)\n";
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $emp = new contacts(null, $hash[$i]["employeenumber"][0]);
        $f[] = @implode(",", $emp->ContactTocsvArray());
    }
    $tmpfile = "/tmp/{$uid}." . time() . ".csv";
    @file_put_contents("{$tmpfile}", @implode("\n", $f));
    $unix = new unix();
    $php = $unix->LOCATE_PHP5_BIN();
    $basename = basename($tmpfile);
    $cmd = $php . " " . dirname(__FILE__) . "/exec.zarafa.csv2contacts.php {$uid} \"{$ct->password}\" {$basename} 2>&1";
    if ($GLOBALS["VERBOSE"]) {
        echo "[{$uid}]: {$cmd}\n";
    }
    exec($cmd, $results);
    if ($GLOBALS["VERBOSE"]) {
        while (list($num, $line) = each($results)) {
            echo "[{$uid}]: {$line}\n";
        }
    }
}
Esempio n. 4
0
function popup_list()
{
    $ou = base64_decode($_GET["ou"]);
    $tpl = new templates();
    $gpid = $_GET["gpid"];
    if ($_POST["query"] != null) {
        $tofind = $_POST["query"];
    }
    $groups = new groups($gpid);
    $group_members = $groups->members_array;
    $ldap = new clladp();
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $tofind = str_replace("**", "*", $tofind);
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber");
    $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
    if (strlen(trim($ldap->ldap_last_error)) > 5) {
        json_error_show("Error:" . $ldap->ldap_last_error);
    }
    $number = $hash["count"];
    $data = array();
    $data['page'] = 1;
    $data['total'] = $number;
    $data['rows'] = array();
    $c = 0;
    for ($i = 0; $i < $number; $i++) {
        $exist = false;
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($uid == null) {
            continue;
        }
        $md = md5($uid);
        $c++;
        if ($uid == "squidinternalauth") {
            continue;
        }
        if ($group_members[$uid]) {
            $exist = true;
        }
        $js = "add_already_member_add('" . base64_encode($uid) . "','{$md}');";
        $mail = texttooltip($userARR["mail"][0], "{add}:{$uid}", $js, null, 0, "font-size:13px");
        $color = "black";
        $add = imgsimple("arrow-right-24.png", "{add}:{$uid}", $js);
        if ($exist) {
            $add = "&nbsp;";
            $color = "#8a8a8a";
        }
        $data['rows'][] = array('id' => "uidS{$md}", 'cell' => array("<span style='font-size:14px;color:{$color}'>{$uid}</span>", "<span style='font-size:14px;color:{$color}'>{$mail}</span>", "<span style='font-size:14px;color:{$color}'>{$add}</span>"));
    }
    echo json_encode($data);
}
Esempio n. 5
0
function popup_list()
{
    $ou = base64_decode($_GET["ou"]);
    $gpid = $_GET["gpid"];
    $tofind = $_GET["search"];
    $groups = new groups($gpid);
    $group_members = $groups->members_array;
    $ldap = new clladp();
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber");
    $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
    if (strlen($ldap->ldap_last_error) != 5) {
        $error = "<H2>{$ldap->ldap_last_error}</H2>";
    }
    $number = $hash["count"];
    $html = "{$error}\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t<th width=1%>" . imgtootltip("refresh-24.png", "{refresh}", "add_already_member_list_refresh()") . "</th>\n\t<th colspan=3>{members}:{$ou}</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    $classtr = null;
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $exist = false;
        $uid = $userARR["uid"][0];
        if ($uid == "squidinternalauth") {
            continue;
        }
        if ($group_members[$uid]) {
            $exist = true;
        }
        $js = "add_already_member_add('" . base64_encode($uid) . "');";
        $sn = texttooltip($userARR["sn"][0], "{add}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{add}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{add}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{add}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{add}:{$uid}", $js, null, 0, "font-size:13px");
        $color = "black";
        $add = imgtootltip("32-plus.png", "{add}:{$uid}", $js);
        if ($exist) {
            $add = "&nbsp;";
            $color = "#CCCCCC";
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1%><img src='img/contact-32.png'></td>\n\t\t\t<td style='font-size:14px;color:{$color}'>{$uid}</td>\n\t\t\t<td style='font-size:14px;color:{$color}'>{$mail}</td>\n\t\t\t<td style='font-size:14px;color:{$color}'>{$add}</td>\n\t\t\t\n\t\t</tr>\n\t\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Esempio n. 6
0
function popup()
{
    $page = CurrentPageName();
    $ldap = new clladp();
    $sock = new sockets();
    $info = $ldap->OUDatas($_GET["ou"]);
    $zarafaEnabled = 1;
    if (!$info["objectClass"]["zarafa-company"]) {
        $zarafaEnabled = 0;
    }
    $ZarafaUserSafeMode = $sock->GET_INFO("ZarafaUserSafeMode");
    $languages = unserialize(base64_decode($sock->getFrameWork("zarafa.php?locales=yes")));
    $langbox[null] = "{select}";
    while (list($index, $data) = each($languages)) {
        $langbox[$data] = $data;
    }
    $t = $_GET["t"];
    if (!is_numeric($t)) {
        $t = time();
    }
    $oumd5 = md5(strtolower(trim($_GET["ou"])));
    $OuDefaultLang = $sock->GET_INFO("zarafaMBXLang{$oumd5}");
    $OuZarafaDeleteADM = $sock->GET_INFO("OuZarafaDeleteADM{$oumd5}");
    $filter = "(&(objectClass=zarafa-user)(zarafaAdmin=1))";
    $attrs = array("displayName", "uid", "mail");
    $dn = "ou={$_GET["ou"]},dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    $number = $hash["count"];
    $arruid[null] = "{select}";
    for ($i = 0; $i < $number; $i++) {
        $userZ = $hash[$i];
        $uid = $userZ["uid"][0];
        $arruid[$uid] = $uid;
    }
    $admin_delete = Field_array_Hash($arruid, "OuZarafaDeleteADM{$t}", $OuZarafaDeleteADM, "style:font-size:16px;padding:3px");
    $mailbox_language = Field_array_Hash($langbox, "zarafaMbxLang{$t}", $OuDefaultLang, "style:font-size:16px;padding:3px");
    if ($OuDefaultLang != null) {
        $rescan = "<div style='width:100%;margin:10px'><center>" . button("{scan_mailboxes_language}", "zarafaDScanMBXLang{$t}()", "16") . "</center></div>";
    }
    if ($ZarafaUserSafeMode == 1) {
        $warn = "\n\t\t\t<hr>\n\t\t\t<table style='width:99 %' class=form>\n\t\t\t<tr>\n\t\t\t<td valign='top'><img src='img/error-64.png'></td>\n\t\t\t<td valign='top'><strong style='font-size:14px'>{ZARAFA_SAFEMODE_EXPLAIN}</td>\n\t\t\t</tr>\n\t\t\t</table>\n\t\t\t\n\t\t\t";
    }
    $enable = Paragraphe_switch_img("{ENABLE_ZARAFA_COMPANY}", "{ENABLE_ZARAFA_COMPANY_TEXT}", "zarafaEnabled", $zarafaEnabled, null, 400);
    $html = "\n\t<div id='{$t}-anim'></div>\n\t<div style='width:98%' class=form>\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td colspan=2>{$enable}</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{default_language}:</td>\n\t\t<td>{$mailbox_language}</td>\n\t</tr>\n\t<tr>\n\t\t<td class=legend style='font-size:16px'>{delete_store_receiver}:</td>\n\t\t<td>{$admin_delete}</td>\n\t</tr>\t\n\t<tr>\n\t<td colspan=2 align='right'>\n\t<hr>" . button("{apply}", "ENABLE_ZARAFA_COMPANY()", 16) . "{$warn}</td>\n\t</tr>\n\t</table>\n\t{$rescan}\n\t</div>\n\t<script>\nvar X_ENABLE_ZARAFA_COMPANY= function (obj) {\n\tvar results=obj.responseText;\n\tif(results.length>3){alert(results);}\n\tdocument.getElementById('{$t}-anim').innerHTML='';\n\t\$('#table-{$t}').flexReload();\n\tif(document.getElementById('organization-find')){SearchOrgs();YahooWin3Hide();return;}\n\tZARAFA_OU_LOAD();\n\t\n\t}\t\n\t\nfunction ENABLE_ZARAFA_COMPANY(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('zarafaEnabled',document.getElementById('zarafaEnabled').value);\n\tXHR.appendData('zarafaMbxLang',document.getElementById('zarafaMbxLang{$t}').value);\n\tXHR.appendData('OuZarafaDeleteADM',document.getElementById('OuZarafaDeleteADM{$t}').value);\n\tXHR.appendData('ou','{$_GET["ou"]}');\n\tAnimateDiv('{$t}-anim');\n\tXHR.sendAndLoad('{$page}', 'GET',X_ENABLE_ZARAFA_COMPANY);\t\n}\n\n\nfunction zarafaDScanMBXLang{$t}(){\n\tvar XHR = new XHRConnection();\n\tXHR.appendData('zarafaScanMbxLang','yes');\n\tXHR.appendData('ou','{$_GET["ou"]}');\n\tAnimateDiv('{$t}-anim');\n\tXHR.sendAndLoad('{$page}', 'POST',X_ENABLE_ZARAFA_COMPANY);\t\n}\n\n</script>\t\n\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
function LDAP_SEARCH_2QUERY($dn = null, $query, $key, $tofind)
{
    $ldap = new clladp();
    if ($dn != null) {
        $dn = $dn . ',' . $ldap->suffix;
    } else {
        $dn = $ldap->suffix;
    }
    $hash = $ldap->Ldap_search($dn, $query, array($tofind, $key));
    for ($z = 0; $z < $hash["count"]; $z++) {
        $value = $hash[$z][$key][0];
        for ($i = 0; $i < $hash[$z][strtolower($tofind)]["count"]; $i++) {
            $res = $res . "{$value}=" . $hash[$z][strtolower($tofind)][$i] . "<br> ";
        }
    }
    return $res;
}
Esempio n. 8
0
function BuildList()
{
    if (!isset($_SESSION["uid"])) {
        if (!logon()) {
            die;
        }
    }
    $users = new usersMenus();
    if (!$users->AsSystemAdministrator) {
        die;
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn=*)(ComputerIP=*)(uid=*))(gecos=computer))";
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType", "ComputerMacAddress", "ComputerRealName", "DnsZoneName", "DnsType");
    $ldap = new clladp();
    $dn = "{$ldap->suffix}";
    $hash["COMPUTERS"] = $ldap->Ldap_search($dn, $filter_search, $attrs);
    $hash["VPN"] = export_vpn_remotes_sites();
    echo base64_encode(serialize($hash));
}
Esempio n. 9
0
function FindComputerByIP()
{
    if ($_GET["SelectDansGuardianExceptionipList"] == '*') {
        $_GET["SelectDansGuardianExceptionipList"] = null;
    }
    if ($_GET["SelectDansGuardianExceptionipList"] == null) {
        $tofind = "*";
    } else {
        $tofind = "{$_GET["SelectDansGuardianExceptionipList"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    writelogs($filter_search, __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerMacAddress", "ComputerMachineType");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 10);
    $html = "<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n<thead class='thead'>\n\t<tr>\n\t\t<th colspan=4>&nbsp;</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $mac = $hash[$i][strtolower("ComputerMacAddress")][0];
        if (trim($ip) == null) {
            continue;
        }
        $js = "AddDansGuardianExceptionipList('{$ip}','{$realuid}');";
        //--enable-arp-acl
        if ($mac != null) {
            $mac = "<br><span style='font-size:10px'>{$mac}</span>";
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $showomp = MEMBER_JS($realuid, 1, 1);
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1% >" . imgtootltip("computer-32.png", '{edit}', "{$showomp}") . "</td>\n\t\t\t<td nowrap><strong style='font-size:14px'>{$hash[$i]["uid"][0]}{$mac}</strong></td>\n\t\t\t<td ><strong style='font-size:14px'>{$ip}</strong></td>\n\t\t\t<td width=1% >" . imgtootltip("plus-24.png", "{add}", $js) . "</td>\n\t\t\t\n\t\t</tr>\n\t";
    }
    $html = $html . "\n</tbody>\n</table>\n</center>\n";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
Esempio n. 10
0
function SyncSafeBoxes()
{
    $ldap = new clladp();
    $pattern = "(&(objectclass=UserArticaClass)(CryptedHome=TRUE))";
    $dn = "dc=organizations,{$ldap->suffix}";
    $filters = array("uid", "CryptedHomePassword", "homeDirectory");
    $hash = $ldap->Ldap_search($dn, $pattern, $filters);
    if ($hash["count"] == 0) {
        return;
    }
    writelogs("{$hash["count"]} user(s) with safe box", __FUNCTION__, __FILE__, __LINE__);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $cryptedhomepassword = $hash[$i]["cryptedhomepassword"][0];
        if ($cryptedhomepassword == null) {
            continue;
        }
        $uid = $hash[$i]["uid"][0];
        $homedirectory = $hash[$i]["homedirectory"][0];
        $dn = $hash[$i]["dn"];
        SafeBoxMount($uid, $dn, $homedirectory, $cryptedhomepassword, $ldap->suffix);
    }
}
Esempio n. 11
0
function computer_list()
{
    if ($_GET["tofind"] == '*') {
        $_GET["tofind"] = null;
    }
    if ($_GET["tofind"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["tofind"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = strtolower(str_replace('$', '', $hash[$i]["uid"][0]));
        $js = MEMBER_JS($realuid, 1);
        $finalHash[$hash[$i]["uid"][0]] = $hash[$i][strtolower("ComputerIP")][0];
    }
    return $finalHash;
}
Esempio n. 12
0
function computer_list()
{
    if ($_GET["tofind"] == '*') {
        $_GET["tofind"] = null;
    }
    if ($_GET["tofind"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["tofind"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 20);
    $PowerDNS = "<td width=1%><h3>&nbsp;|&nbsp;</h3></td><td><h3>" . texttooltip('{APP_PDNS}', '{APP_PDNS_TEXT}', "javascript:Loadjs('pdns.php')") . "</h3></td>";
    if ($_GET["mode"] == "selection") {
        $PowerDNS = null;
    }
    $html = "\n\n<input type='hidden' id='mode' value='{$_GET["mode"]}' name='mode'>\n<input type='hidden' id='value' value='{$_GET["value"]}' name='value'>\n<input type='hidden' id='callback' value='{$_GET["callback"]}' name='callback'>\n<table style='width:100%'><tr>\n<td width=1% nowrap><H3>{$hash["count"]} {computers}</H3></td>{$PowerDNS}</tr></table>\n<table style='width:100%'>";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $js = MEMBER_JS($realuid, 1);
        if ($_GET["mode"] == "dansguardian-ip-group") {
            $js_add = "<td width=1%>" . imgtootltip('add-18.gif', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
        }
        if ($_GET["mode"] == "selection") {
            $js = "{$_GET["callback"]}('{$realuid}');";
        }
        $roolover = CellRollOver($js);
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $os = $hash[$i][strtolower("ComputerOS")][0];
        $type = $hash[$i][strtolower("ComputerMachineType")][0];
        $name = $hash[$i]["uid"][0];
        if (strlen($name) > 25) {
            $name = substr($name, 0, 23) . "...";
        }
        if ($os == "Unknown") {
            if ($type != "Unknown") {
                $os = $type;
            }
        }
        if (strlen($os) > 20) {
            $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
        }
        if (strlen($ip) > 20) {
            $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
        }
        $html = $html . "<tr>\n\t<td width=1% {$roolover}><img src='img/base.gif'></td>\n\t<td {$roolover} nowrap><strong>{$name}</strong></td>\n\t<td {$roolover}><strong>{$ip}</strong></td>\n\t<td {$roolover}><strong>{$os}</strong></td>\n\t{$js_add}\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
function users_search_ldap()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $ldap = new clladp();
    $ou = $_GET["ou"];
    $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
    if ($_GET["search-users-ldap"] != null) {
        $tofind = $_GET["search-users-ldap"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    $hash = $ldap->Ldap_search($dn, $filter, $attrs, 550);
    $boot = new boostrap_form();
    $users = new user();
    $number = $hash["count"];
    $styleTD = " style='font-size:16px'";
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $link = $boot->trswitch("{$_GET["CallBack"]}('{$uid}')");
        $tr[] = "\n\t\t<tr id='{$id}'>\n\t\t<td {$styleTD} width=99% nowrap {$link}><i class='icon-user'></i>&nbsp;{$userARR["sn"][0]} {$userARR["givenname"][0]}<div><i>{$userARR["title"][0]}</i></td>\n\t\t<td {$styleTD} width=99% nowrap {$link}>{$userARR["telephonenumber"][0]}</td>\n\t\t<td {$styleTD} width=99% nowrap {$link}>{$userARR["mail"][0]}</td>\n\t\t</tr>";
    }
    echo $tpl->_ENGINE_parse_body("\n\t\n\t\t<table class='table table-bordered table-hover'>\n\t\n\t\t\t<thead>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>{member}</th>\n\t\t\t\t\t<th>{phone}</th>\n\t\t\t\t\t<th>{email}</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t <tbody>\n\t\t\t") . @implode("\n", $tr) . " </tbody>\n\t\t\t\t</table>";
}
Esempio n. 14
0
function SimpleShareSearch()
{
    if ($_GET["SimpleShareSearch"] == '*') {
        $_GET["SimpleShareSearch"] = null;
    }
    if ($_GET["SimpleShareSearch"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["SimpleShareSearch"]}*";
    }
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType", "ComputerMacAddress");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, 20);
    $html = "<table class=tableView>\n\t<thead class=thead>\n\t<tr>\n\t\t<th colspan=2>{computers} ({$tofind})</th>\n\t\t<th colspan=2>{ip_address}</th>\n\t</tr>\n\t</thead>\n\n\n";
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $js_show = MEMBER_JS($realuid, 1);
        if ($_GET["callback"] != null) {
            $js_selection = "{$_GET["callback"]}('{$realuid}');";
        }
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $os = $hash[$i][strtolower("ComputerOS")][0];
        $type = $hash[$i][strtolower("ComputerMachineType")][0];
        $mac = $hash[$i][strtolower("ComputerMacAddress")][0];
        $name = $hash[$i]["uid"][0];
        if (strlen($name) > 25) {
            $name = substr($name, 0, 23) . "...";
        }
        if ($os == "Unknown") {
            if ($type != "Unknown") {
                $os = $type;
            }
        }
        if (!preg_match("#^[0-9]+\\.[0-9]+#", $ip)) {
            $ip = $ip = "0.0.0.0";
        }
        if (strlen($os) > 20) {
            $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
        }
        if (strlen($ip) > 20) {
            $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
        }
        $img = "<img src='img/base.gif'>";
        if ($cl == "oddRow") {
            $cl = null;
        } else {
            $cl = "oddRow";
        }
        $roolover = CellRollOver($js_selection, "{select}");
        $html = $html . "<tr class={$cl}>\n\t<td width=1% {$roolover}>{$img}</td>\n\t<td nowrap width=99%><strong style='font-size:12px'>{$name}</strong></td>\n\t<td width=2% nowrap><strong style='font-size:12px'>{$ip}</strong></td>\n\t<td width=1%>" . imgtootltip("plus-24.png", "{add}", "SimpleSearchAddComputerPath('{$realuid}')") . "</td>\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Esempio n. 15
0
function find_member()
{
    if ($_POST["qtype"] == "find-member") {
        $tofind = $_POST["query"];
    }
    if ($_SESSION["uid"] == -100) {
        $ou = $_GET["ou"];
    } else {
        $ou = $_SESSION["ou"];
    }
    $sock = new sockets();
    if (is_base64_encoded($ou)) {
        $ou = base64_decode($ou);
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $tofind = str_replace('***', '*', $tofind);
    $tofind = str_replace('**', '*', $tofind);
    $tofind = str_replace('**', '*', $tofind);
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    writelogs("FIND {$tofind} IN OU \"{$ou}\"", __FUNCTION__, __FILE__, __LINE__);
    $ldap = new clladp();
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $cc = new ldapAD();
            $hash = $cc->find_users($ou, $tofind);
        } else {
            $ldap = new clladp();
            $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind}) ))";
            $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
            $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
            $hash = $ldap->Ldap_search($dn, $filter, $attrs, 20);
        }
    } else {
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $p = new external_ad_search();
        $hash = $p->find_users($ou, $tofind);
        $ldap->EnableManageUsersTroughActiveDirectory = true;
    }
    $users = new user();
    $number = $hash["count"];
    $data = array();
    $data['page'] = 0;
    $data['total'] = $number;
    $data['rows'] = array();
    for ($i = 0; $i < $number; $i++) {
        $user = $hash[$i];
        $data['rows'][] = formatUser($user, $ldap->EnableManageUsersTroughActiveDirectory);
    }
    echo json_encode($data);
}
Esempio n. 16
0
function MembersSearch()
{
    $ldap = new clladp();
    $tofind = $_POST["query"];
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    $hash = $ldap->Ldap_search($ldap->suffix, $filter, $attrs, $_POST["rp"]);
    $users = new user();
    $number = $hash["count"];
    if ($number == 0) {
        json_error_show("no member");
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = $number;
    $data['rows'] = array();
    $color = "black";
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        $uidenc = urlencode($uid);
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        $jsbl = "javascript:Loadjs('whitelists.members.php?uid={$uidenc}');";
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $ct = new user($uid);
        $CountDeBlack = count($ct->amavisBlacklistSender);
        $countDeWhite = count($ct->amavisWhitelistSender);
        $id = md5("{$uid}");
        $data['rows'][] = array('id' => $id, 'cell' => array("<span style='font-size:22px;color:{$color}'><a href=\"javascript:blur();\" OnClick=\"{$jsbl}\" style='text-decoration:underline'>{$userARR["givenname"][0]} {$userARR["sn"][0]}</a>\n\t\t\t\t\t\t<br><i style='font-size:14px'><a href=\"javascript:blur();\" OnClick=\"{$js}\" style='text-decoration:underline'>{$uid} {$userARR["mail"][0]}</a></i></span>", "<span style='font-size:22px;color:{$color}'>{$CountDeBlack}</span>", "<span style='font-size:22px;color:{$color}'>{$countDeWhite}</span>"));
    }
    echo json_encode($data);
}
Esempio n. 17
0
function COMPUTER_FIND()
{
    $gpid = $_GET["gpid"];
    $ou = $_GET["ou"];
    $tofind = $_GET["find_computer"];
    $ldap = new clladp();
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $attrs = array("uid", "ComputerIP", "ComputerOS");
    $dn = "dc=samba,{$ldap->suffix}";
    $html = "\n<input type='hidden' id='add_computer_confirm' value='{add_computer_confirm}'>\n<table style='width:100%'>";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $html = $html . "<tr " . CellRollOver() . ">\n\t<td width=1%><img src='img/base.gif'></td>\n\t<td><strong>{$hash[$i]["uid"][0]}</strong></td>\n\t<td><strong>{$hash[$i][strtolower("ComputerIP")][0]}</strong></td>\n\t<td><strong>{$hash[$i][strtolower("ComputerOS")][0]}</strong></td>\n\t<td width=1%>" . imgtootltip('plus-16.png', '{add_computer}', "javascript:add_computer_selected('{$gpid}','{$hash[$i]["dn"]}','{$hash[$i]["uid"][0]}','{$realuid}')") . "</td>\n\t</tr>\n\t";
    }
    $html = $html . "</table>";
    $html = RoundedLightGrey($html);
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Esempio n. 18
0
function RELAY_DOMAINS_LIST_SEARCH()
{
    $ldap = new clladp();
    $page = CurrentPageName();
    $tpl = new templates();
    $users = new usersMenus();
    $ou = $_GET["ou"];
    include_once "ressources/class.amavis.inc";
    $amavis = new amavis();
    $amavis_oui = false;
    $t = $_GET["t"];
    writelogs("----------------> Hash_relay_domains", __FUNCTION__, __FILE__, __LINE__);
    $HashDomains = $ldap->Hash_relay_domains($ou);
    $aliases = new AutoAliases($ou);
    $users->LoadModulesEnabled();
    if ($users->AMAVIS_INSTALLED) {
        if ($users->EnableAmavisDaemon == 1) {
            $amavis_oui = true;
        }
    }
    $disclaimer = IS_DISCLAIMER();
    $tools = new DomainsTools();
    $domainstyle = "font-size:16px";
    if (isset($_GET["expand"])) {
        $domainstyle = "font-size:18px";
    }
    if ($_POST["query"] != null) {
        $search = str_replace("*", ".*?", $_POST["query"]);
    }
    $data = array();
    $c = 0;
    while (list($num, $ligne) = each($HashDomains)) {
        if ($search != null) {
            if (!preg_match("#{$search}#", $num)) {
                continue;
            }
        }
        $c++;
        $autoalias = "&nbsp;";
        $disclaimer_domain = "&nbsp;";
        $amavis_infos = "&nbsp;";
        $amavis_duplicate = "&nbsp;";
        $delete = imgtootltip("delete-24.png", '{label_delete_transport}', "DeleteRelayDomain{$t}('{$num}')");
        if ($amavis->copy_to_domain_array[strtolower($num)]["enable"] == 1) {
            $amavis_duplicate = "<strong style='font-size:12px'>{$amavis->copy_to_domain_array[strtolower($num)]["duplicate_host"]}:{$amavis->copy_to_domain_array[strtolower($num)]["duplicate_port"]}";
        }
        $autoalias = $tpl->_ENGINE_parse_body($autoalias);
        writelogs("add in row {$ligne} ", __FUNCTION__, __FILE__);
        $arr = $tools->transport_maps_explode($ligne);
        $alreadyDomain[$num] = true;
        $count++;
        $js = "Loadjs('domains.relay.domains.php?domain={$num}&ou={$ou}')";
        $relay = "{$arr[1]}:{$arr[2]}";
        if (strlen($aliases->DomainsArray[$num]) > 0) {
            $autoalias = "<img src='img/20-check.png'>";
        }
        if ($arr[3] == "yes") {
            $mx = "{yes}";
        } else {
            $mx = "{no}";
        }
        if ($amavis_oui) {
            $amavis_infos = imgtootltip("24-parameters.png", "AS -> {$num}", "Loadjs('domains.amavis.php?domain={$num}')");
        }
        if ($disclaimer) {
            $disclaimer_domain = imgtootltip("24-parameters.png", "disclaimer -> {$num}", "Loadjs('domains.disclaimer.php?domain={$num}&ou={$ou}')");
        }
        $data['rows'][] = array('id' => "dom-{$num}", 'cell' => array("\n\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='{$domainstyle};font-weight:bold;text-decoration:underline'>{$num}</span>", "<span style='font-size:14px'>{$autoalias}</span>", "<span style='font-size:14px'>{$amavis_infos}</span>", "<span style='font-size:14px'>{$disclaimer_domain}</span>", "<span style='font-size:14px'>{$relay}</span>", $delete));
    }
    $dn = "cn=transport_map,ou={$ou},dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, '(objectclass=transportTable)', array());
    for ($i = 0; $i < $hash["count"]; $i++) {
        $transport = $hash[$i]["transport"][0];
        $domain = $hash[$i]["cn"][0];
        if (isset($alreadyDomain[$domain])) {
            continue;
        }
        if ($search != null) {
            if (!preg_match("#{$search}#", $domain)) {
                continue;
            }
        }
        $arr = $tools->transport_maps_explode($transport);
        $relay = "{$arr[1]}:{$arr[2]}";
        $js = "PostfixAddRoutingTable('{$domain}')";
        $count++;
        $data['rows'][] = array('id' => "dom-{$domain}", 'cell' => array("\n\t\t\t<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='font-size:16px;font-weight:bold;text-decoration:underline'>{$domain}</span>", "<span style='font-size:14px'>&nbsp;</span>", "<span style='font-size:14px'>&nbsp;</span>", "<span style='font-size:14px'>&nbsp;</span>", "<span style='font-size:14px'>{$relay}</span>", "&nbsp;"));
    }
    $data['page'] = 1;
    $data['total'] = $c;
    echo json_encode($data);
}
Esempio n. 19
0
function computer_list()
{
    $tofindorg = $_POST["query"];
    $tpl = new templates();
    $_GET["tofind"] = $_POST["query"];
    $MyPage = CurrentPageName();
    if ($_GET["tofind"] == '*') {
        $_GET["tofind"] = null;
    }
    if ($_GET["tofind"] == null) {
        $tofind = "*";
    } else {
        $tofind = "*{$_GET["tofind"]}*";
    }
    $tofind = str_replace("**", "*", $tofind);
    $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn={$tofind})(ComputerIP={$tofind})(uid={$tofind}))(gecos=computer))";
    $ldap = new clladp();
    $attrs = array("uid", "ComputerIP", "ComputerOS", "ComputerMachineType", "ComputerMacAddress");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs, $_POST["rp"]);
    if (IsPhysicalAddress($tofindorg)) {
        $tofind = strtolower($tofindorg);
        $tofind = str_replace('-', ":", $tofind);
        $patternMac = "(&(objectclass=posixAccount)(ComputerMacAddress={$tofind}))";
        $hash2 = $ldap->Ldap_search($dn, $patternMac, $attrs, $_POST["rp"]);
    }
    $spanStyle = "<span style='font-size:14px;font-weight:bold'>";
    $data['page'] = 1;
    $data['total'] = $hash["count"];
    $data['rows'] = array();
    $c = 0;
    $unknown = $tpl->_ENGINE_parse_body("{unknown}");
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        $hash[$i]["uid"][0] = str_replace('$', '', $hash[$i]["uid"][0]);
        $js = MEMBER_JS($realuid, 1);
        $Alreadyrealuid[$realuid] = true;
        if ($_GET["mode"] == "dansguardian-ip-group") {
            $js_add = "<td width=1%>" . imgtootltip('add-18.png', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
        }
        if ($_GET["mode"] == "selection") {
            $js = "{$_GET["callback"]}('{$realuid}');";
        }
        $ip = $hash[$i][strtolower("ComputerIP")][0];
        $os = $hash[$i][strtolower("ComputerOS")][0];
        $type = $hash[$i][strtolower("ComputerMachineType")][0];
        $name = $hash[$i]["uid"][0];
        if ($os == "Unknown") {
            if ($type != "Unknown") {
                $os = $type;
            }
        }
        $js = str_replace("javascript:", '', $js);
        $md5S = md5(serialize($hash[$i]));
        if (!preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $ip)) {
            $ip = gethostbyname($hash[$i]["uid"][0]);
            if (!preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$#", $ip)) {
                $ip = $unknown;
            } else {
                $computer = new computers($realuid);
                $computer->update_ipaddr($ip);
            }
        }
        if ($os == "UnKnown") {
            $os = $unknown;
        }
        $c++;
        $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?computer-delete-js=yes&uid={$realuid}&id={$md5S}')");
        $data['rows'][] = array('id' => $md5S, 'cell' => array("<img src='img/computer-32.png'>", "<a href='#' OnClick=\"javascript:{$js}\" style='font-size:14px;text-decoration:underline;font-weight:bold'>{$name}</a>", "{$spanStyle}{$ip}</span>", "{$spanStyle}{$os}</span>", $delete));
    }
    if (is_array($hash2)) {
        for ($i = 0; $i < $hash2["count"]; $i++) {
            $realuid = $hash2[$i]["uid"][0];
            if (isset($Alreadyrealuid[$realuid])) {
                continue;
            }
            $hash2[$i]["uid"][0] = str_replace('$', '', $hash2[$i]["uid"][0]);
            $js = MEMBER_JS($realuid, 1);
            $Alreadyrealuid[$realuid] = true;
            if ($_GET["mode"] == "dansguardian-ip-group") {
                $js_add = "<td width=1%>" . imgtootltip('add-18.png', "{add_computer}", "AddComputerToDansGuardian('{$realuid}','{$_GET["value"]}')") . "</td>";
            }
            if ($_GET["mode"] == "selection") {
                $js = "{$_GET["callback"]}('{$realuid}');";
            }
            $ip = $hash2[$i][strtolower("ComputerIP")][0];
            $os = $hash2[$i][strtolower("ComputerOS")][0];
            $type = $hash2[$i][strtolower("ComputerMachineType")][0];
            $name = $hash2[$i]["uid"][0];
            if (strlen($name) > 25) {
                $name = substr($name, 0, 23) . "...";
            }
            if ($os == "Unknown") {
                if ($type != "Unknown") {
                    $os = $type;
                }
            }
            if (strlen($os) > 20) {
                $os = texttooltip(substr($os, 0, 17) . '...', $os, null, null, 1);
            }
            if (strlen($ip) > 20) {
                $ip = texttooltip(substr($ip, 0, 17) . '...', $ip, null, null, 1);
            }
            $js = str_replace("javascript:", '', $js);
            $md5S = md5(serialize($hash2[$i]));
            $delete = imgsimple("delete-24.png", null, "Loadjs('{$MyPage}?computer-delete-js=yes&uid={$realuid}&id={$md5S}');");
            $c++;
            $data['rows'][] = array('id' => $md5S, 'cell' => array("<img src='img/computer-32.png'>", "<a href='#' OnClick=\"javascript:{$js}\" style='font-size:13px;text-decoration:underline'>{$name}</a>", "{$spanStyle}{$ip}</span>", "{$spanStyle}{$os}</span>", $delete));
        }
    }
    $data['total'] = $c;
    if ($c == 0) {
        json_error_show("no item");
    }
    echo json_encode($data);
}
Esempio n. 20
0
function cachednshosts_records($g)
{
    $unix = new unix();
    if (!is_array($g)) {
        $g = array();
    }
    $build_hosts_array = unserialize(@file_get_contents("/etc/dnsmasq.hash.domains"));
    $sock = new sockets();
    $IpClass = new IP();
    $EnableDNSMASQOCSDB = $sock->GET_INFO("EnableDNSMASQOCSDB");
    $EnableDHCPServer = intval($sock->GET_INFO("EnableDHCPServer"));
    $EnableDNSMASQLDAPDB = $sock->GET_INFO("EnableDNSMASQLDAPDB");
    if (!is_numeric($EnableDNSMASQOCSDB)) {
        $EnableDNSMASQOCSDB = 1;
    }
    if (!is_numeric($EnableDNSMASQLDAPDB)) {
        $EnableDNSMASQLDAPDB = 0;
    }
    $EnableArticaHotSpot = intval($sock->GET_INFO("EnableArticaHotSpot"));
    $C = 0;
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Use OCS database {$EnableDNSMASQOCSDB}\n";
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Use LDAP database {$EnableDNSMASQLDAPDB}\n";
    }
    $q = new mysql_squid_builder();
    $qSquid = new mysql_squid_builder();
    $sql = "SELECT * FROM dnsmasq_records";
    $results = $q->QUERY_SQL($sql);
    if (!$q->ok) {
        $GLOBALS["MYSQL_ERROR_DNSMASQ"] = true;
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} MySQL error, aborting\n";
        }
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} {$q->mysql_error}\n";
        }
        return false;
    }
    $CNAMES = array();
    $MAIN_MEM = array();
    @unlink("/etc/dnsmasq.hosts.cmdline");
    while ($ligne = mysql_fetch_assoc($results)) {
        $ipaddr = trim($ligne["ipaddr"]);
        $hostname = hostname_valid($ligne["hostname"]);
        if ($GLOBALS["OUTPUT"]) {
            echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]} host: {$hostname}/{$ipaddr}\n";
        }
        if ($hostname == null) {
            continue;
        }
        if (strpos($hostname, ".") > 0) {
            $build_hosts_array[$q->GetFamilySites($hostname)] = true;
        }
        if (strpos($hostname, ".") > 0) {
            $hostname_EXPLODED = explode(".", $hostname);
            $MAIN_MEM[$ipaddr][] = $hostname_EXPLODED[0];
        }
        push_ptr($hostname, $ipaddr);
        $results2 = $q->QUERY_SQL("SELECT hostname FROM dnsmasq_cname WHERE recordid={$ligne["ID"]}");
        $aliases = array();
        while ($ligne2 = mysql_fetch_assoc($results2)) {
            if (trim(hostname_valid($ligne2["hostname"])) == null) {
                continue;
            }
            $aliases[] = $ligne2["hostname"];
            $C++;
            $GLOBALS["CNAMES"][$ligne2["hostname"]] = "--cname={$ligne2["hostname"]},{$ipaddr}";
            if ($GLOBALS["VERBOSE"]) {
                echo "{$hostname} -> {$ligne2["hostname"]}\n";
            }
        }
    }
    if ($EnableDHCPServer == 1) {
        $q = new mysql();
        $results = $q->QUERY_SQL("SELECT * FROM dhcpd_fixed", "artica_backup");
        if (!$q->ok) {
            return;
        }
        $c = 0;
        while ($ligne = mysql_fetch_assoc($results)) {
            $ligne["hostname"] = hostname_valid($ligne["hostname"]);
            if ($ligne["hostname"] == null) {
                continue;
            }
            $arecord = $ligne["ipaddr"];
            $hostname = $ligne["hostname"];
            if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.#", $hostname)) {
                continue;
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "[" . __LINE__ . "] dhcpd_fixed::{$hostname}/{$arecord}\n";
            }
            if (strpos($hostname, ".") > 0) {
                $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true;
            }
            push_ptr($hostname, $arecord);
            if ($GLOBALS["VERBOSE"]) {
                echo "dhcpd_fixed:: {$hostname} -> {$ipaddr}\n";
            }
        }
    }
    if ($EnableArticaHotSpot == 1) {
        $HospotHTTPServerName = trim($sock->GET_INFO("HospotHTTPServerName"));
        if ($HospotHTTPServerName != null) {
            $ArticaHotSpotInterface = $sock->GET_INFO("ArticaHotSpotInterface");
            $NETWORK_ALL_INTERFACES = $unix->NETWORK_ALL_INTERFACES();
            $IPADDR = $NETWORK_ALL_INTERFACES[$ArticaHotSpotInterface]["IPADDR"];
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, adding {$HospotHTTPServerName}/{$IPADDR}\n";
            }
            if (strpos($HospotHTTPServerName, ".") > 0) {
                $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true;
            }
            push_ptr($HospotHTTPServerName, $IPADDR);
            $C++;
        }
    }
    if ($EnableDNSMASQOCSDB == 1) {
        $sql = "SELECT networks.IPADDRESS,hardware.name FROM networks,hardware WHERE \tnetworks.HARDWARE_ID=hardware.ID\n\t\t\tAND networks.IPADDRESS!='0.0.0.0' AND networks.IPADDRESS REGEXP '^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\$'";
        $q = new mysql();
        $results = $q->QUERY_SQL($sql, "ocsweb");
        if ($GLOBALS["VERBOSE"]) {
            if (!$q->ok) {
                echo $q->mysql_error . "\n";
            }
        }
        if ($GLOBALS["VERBOSE"]) {
            echo "[" . __LINE__ . "] ocs_addresses:: MYSQL -> " . mysql_num_rows($results) . " entries\n";
        }
        while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
            $arecord = $ligne["IPADDRESS"];
            $hostname = hostname_valid($ligne["name"]);
            if ($hostname == null) {
                continue;
            }
            if (preg_match("#^[0-9]+\\.[0-9]+\\.[0-9]+\\.[0-9]+\\.#", $hostname)) {
                continue;
            }
            if ($GLOBALS["VERBOSE"]) {
                echo "[" . __LINE__ . "] ocs_addresses:: {$hostname}/{$arecord} OCS MYSQL\n";
            }
            if (strpos($hostname, ".") > 0) {
                $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true;
            }
            $C++;
            push_ptr($hostname, $arecord);
            if ($GLOBALS["VERBOSE"]) {
                echo "OCS:: {$hostname} -> {$ipaddr}\n";
            }
        }
    }
    if ($EnableDNSMASQLDAPDB == 1) {
        $ldap = new clladp();
        $filter_search = "(&(objectClass=ArticaComputerInfos)(|(cn=*)(ComputerIP=*)(uid=*))(gecos=computer))";
        $ldap = new clladp();
        $attrs = array("uid", "ComputerIP");
        $dn = "{$ldap->suffix}";
        $hash = $ldap->Ldap_search($dn, $filter_search, $attrs);
        for ($i = 0; $i < $hash["count"]; $i++) {
            $arecord = $hash[$i][strtolower("ComputerIP")][0];
            $hostname = trim(strtolower($hash[$i]["uid"][0]));
            $hostname = hostname_valid($hostname);
            if ($hostname == null) {
                continue;
            }
            if ($arecord == "127.0.0.1") {
                continue;
            }
            if ($arecord == "0.0.0.0") {
                continue;
            }
            if ($arecord == null) {
                continue;
            }
            if (isset($GLOBALS["ARRAY_ADRESSES_DONE"][$hostname])) {
                continue;
            }
            if (!$IpClass->isValid($arecord)) {
                continue;
            }
            if (strpos($hostname, ".") > 0) {
                $build_hosts_array[$qSquid->GetFamilySites($hostname)] = true;
            }
            $reversed = reversed_name($arecord);
            $C++;
            push_ptr($hostname, $arecord);
            if ($GLOBALS["VERBOSE"]) {
                echo "LDAP:: {$hostname} -> {$arecord}\n";
            }
        }
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, " . count($GLOBALS["PTR_RECORDS"]) . " Records...\n";
    }
    while (list($arecord, $hostnames) = each($GLOBALS["PTR_RECORDS"])) {
        if ($arecord == "0.0.0.0") {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Invalid `{$arecord}/{$hostnames}`\n";
            }
            continue;
        }
        $netbiosname = hostname_valid($hostnames[0]);
        $FullyHostname = hostname_valid($hostnames[1]);
        if ($netbiosname == null) {
            if ($GLOBALS["OUTPUT"]) {
                echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, Invalid hostname_valid():`{$arecord}/{$hostnames[0]}`\n";
            }
            continue;
        }
        $hostname_text = @implode("/", $hostnames);
        $hostname = $hostnames[0];
        $hostname = str_replace(" ", "", $hostname);
        $reversed = reversed_name($arecord);
        $g[] = "--address=/{$hostname_text}/{$arecord}";
        $g[] = "--ptr-record={$reversed}.in-addr.arpa.,{$hostname}";
    }
    while (list($arecord, $cmdline) = each($GLOBALS["CNAMES"])) {
        $g[] = $cmdline;
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, {$C} host(s)\n";
    }
    @file_put_contents("/etc/dnsmasq.hash.domains", serialize($build_hosts_array));
    $g = GetGoogleWebsitesList($g);
    if (count($g) > 0) {
        @file_put_contents("/etc/dnsmasq.hosts.cmdline", @implode(" ", $g));
    }
    if ($GLOBALS["OUTPUT"]) {
        echo "Starting......: " . date("H:i:s") . " [INIT]: {$GLOBALS["TITLENAME"]}, return " . count($g) . " host item(s)\n";
    }
    return $g;
}
function sender_dependent_relayhosts_maps()
{
    $ldap = new clladp();
    $filter = "(&(objectClass=SenderDependentRelayhostMaps)(cn=*))";
    $attrs = array("cn", "SenderRelayHost", "dn");
    $dn = "cn=Sender_Dependent_Relay_host_Maps,cn=artica,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $mail = $hash[$i]["cn"][0];
        $value = trim($hash[$i][strtolower("SenderRelayHost")][0]);
        $sender_dependent_relayhost_maps[$mail] = array("PASSWORD" => "{$value}", "type" => "dn", "value" => "{$hash[$i]["dn"]}");
    }
    $filter = "(&(objectClass=userAccount)(mail=*))";
    $attrs = array("mail", "AlternateSmtpRelay", "uid");
    $dn = "dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $mail = $hash[$i]["mail"][0];
        $value = trim($hash[$i][strtolower("AlternateSmtpRelay")][0]);
        if ($value == null) {
            continue;
        }
        $sender_dependent_relayhost_maps[$mail] = array("PASSWORD" => "{$value}", "type" => "uid", "value" => "{$hash[$i]["uid"][0]}");
    }
    $filter = "(&(objectClass=SenderDependentSaslInfos)(cn=*))";
    $attrs = array("cn", "SenderCanonicalRelayHost", "dn");
    $dn = "dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $mail = $hash[$i]["cn"][0];
        $value = trim($hash[$i][strtolower("SenderCanonicalRelayHost")][0]);
        $sender_dependent_relayhost_maps[$mail] = array("PASSWORD" => "{$value}", "type" => "dn", "value" => "{$hash[$i]["dn"]}");
    }
    return $sender_dependent_relayhost_maps;
}
Esempio n. 22
0
function transport_maps_search()
{
    $ldap = new clladp();
    $unix = new unix();
    $sock = new sockets();
    $PostfixLocalDomainToRemote = $sock->GET_INFO("PostfixLocalDomainToRemote");
    if (!is_numeric($PostfixLocalDomainToRemote)) {
        $PostfixLocalDomainToRemote = 0;
    }
    $PostfixLocalDomainToRemoteAddr = $sock->GET_INFO("PostfixLocalDomainToRemoteAddr");
    if (!isset($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"])) {
        $GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"] = array();
    }
    //----------------------------------------------------------------------------------------------------------
    $filter = "(&(objectClass=transportTable)(cn=*))";
    $attrs = array("cn", "transport");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $domain = $hash[$i]["cn"][0];
        $transport = $hash[$i]["transport"][0];
        if (substr($domain, 0, 1) == "@") {
            $domain = substr($domain, 1, strlen($domain));
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
        }
        if (strpos("  {$domain}", "@") == 0) {
            $domain = "@{$domain}";
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$domain}"] = true;
    }
    //----------------------------------------------------------------------------------------------------------
    if ($PostfixLocalDomainToRemote == 1) {
        $filter = "(&(objectClass=organizationalUnit)(associatedDomain=*))";
        $attrs = array("associatedDomain");
        $dn = "{$ldap->suffix}";
        $hash = $ldap->Ldap_search($dn, $filter, $attrs);
        $transport = "smtp:{$PostfixLocalDomainToRemoteAddr}";
        for ($i = 0; $i < $hash["count"]; $i++) {
            for ($t = 0; $t < $hash[$i]["associateddomain"]["count"]; $t++) {
                $domain = $hash[$i][strtolower("associatedDomain")][$t];
                if (substr($domain, 0, 1) == "@") {
                    $domain = substr($domain, 1, strlen($domain));
                }
                if (!$GLOBALS["transport_mem"]["{$domain}"]) {
                    $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
                }
                if (strpos("  {$domain}", "@") == 0) {
                    $domain = "@{$domain}";
                }
                if (!$GLOBALS["transport_mem"]["{$domain}"]) {
                    $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
                }
                $GLOBALS["transport_mem"]["{$domain}"] = true;
            }
        }
    }
    //----------------------------------------------------------------------------------------------------------
    $t = 0;
    if (count($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"]) > 0) {
        while (list($domain, $targeted_ip) = each($GLOBALS["REMOTE_SMTP_LDAPDB_ROUTING"])) {
            $transport = "relay[{$targeted_ip}]:25";
            if (!$GLOBALS["transport_mem"]["@{$domain}"]) {
                $t++;
                $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
                $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
            }
            $GLOBALS["transport_mem"]["@{$domain}"] = true;
        }
    }
    echo "Starting......: " . date("H:i:s") . " Postfix {$t} routed domains from external sources\n";
    $dn = "cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
    $filter = "(&(objectClass=InternalRecipients)(cn=*))";
    $attrs = array("cn", "ArticaSMTPSenderTable");
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $email = $hash[$i]["cn"][0];
        $transport = $hash[$i][strtolower("ArticaSMTPSenderTable")][0];
        $uid = $ldap->uid_from_email($email);
        if ($uid != null) {
            continue;
        }
        if (!$GLOBALS["transport_mem"]["{$email}"]) {
            $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
    $sql = "SELECT *  FROM postfix_transport_recipients WHERE hostname='master' AND enabled=1";
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "artica_backup");
    if (!$q->ok) {
        $unix->send_email_events("Fatal: {$q->mysql_error}", "function:" . __FUNCTION__ . "\nFile:" . __FILE__ . "\nLIne:" . __LINE__, "postfix");
    }
    while ($ligne = mysql_fetch_assoc($results)) {
        $email = $ligne["recipient"];
        $transport = $ligne["transport"];
        if (isset($GLOBALS["transport_mem"]["{$email}"])) {
            continue;
        }
        $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
}
Esempio n. 23
0
function zone_hosts_lits($zone)
{
    $ldap = new clladp();
    $query = "(&(objectClass=ArticaComputerInfos)(DnsZoneName={$zone}))";
    $filter = array();
    if ($_GET["search-hosts"] != null) {
        $pattern = $_GET["search-hosts"];
        $tbl = explode(' ', $pattern);
        $searchzone = "(DnsZoneName={$_GET["zone"]})";
        if (trim($tbl[1]) == "all") {
            $searchzone = null;
            $pattern = $tbl[0];
        }
        $query = "(&(objectClass=ArticaComputerInfos)(|(cn={$pattern})(ComputerIP={$pattern})){$searchzone})";
    }
    $hash = $ldap->Ldap_search($ldap->suffix, $query, $filter);
    $html = "<strong>{$hash["count"]} {computers}</strong><br>\n\t<input type='hidden' id='patterfind' value='{$_GET["search-hosts"]}'>\n\t";
    $count = $hash["count"];
    if ($count > 18) {
        $count = 18;
    }
    for ($i = 0; $i < $count; $i++) {
        $uid = str_replace('$', '', $hash[$i]["uid"][0]);
        $ip = $hash[$i]["computerip"][0];
        $type = $hash[$i]["dnstype"][0];
        $html = $html . "\n\t\t\n\t\t<div style='float:left;width:120px;margin:2px;padding:2px;border:1px solid white' " . CellRollOver("YahooWin2(670,'domains.edit.user.php?userid={$uid}\$&ajaxmode=yes')") . ">\n\t\t<table style='width:100%'>\n\t\t<tr>\n\t\t<td valign='top' width=1%><img src='img/workstation-linux-32.png'></td>\n\t\t<td valign='top'><strong style='font-size:11px'>{$uid}</strong>\n\t\t<br>{$ip}<br>{type}:{$type}\n\t\t</td>\n\t\t</tr>\n\t\t</table>\n\t\t</div>\n\t\t\n\t\t";
    }
    $tpl = new templates();
    return $tpl->_ENGINE_parse_body($html);
}
function sender_canonical_maps_build()
{
    $ldap = new clladp();
    $filter = "(&(objectClass=userAccount)(mail=*))";
    $attrs = array("mail", "SenderCanonical");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $mail = $hash[$i]["mail"][0];
        if (!isset($hash[$i][strtolower("SenderCanonical")])) {
            continue;
        }
        $canonical = $hash[$i][strtolower("SenderCanonical")][0];
        if ($canonical == null) {
            continue;
        }
        $GLOBALS["sender_canonical_maps"][] = "{$mail}\t{$canonical}";
        $GLOBALS["smtp_generic_maps"][] = "{$mail}\t{$canonical}";
    }
    $q = new mysql();
    if (!$q->FIELD_EXISTS("smtp_generic_maps", "sender_canonical_maps", "artica_backup")) {
        $sql = "ALTER TABLE `smtp_generic_maps` ADD `sender_canonical_maps` smallint(1)  NOT NULL DEFAULT '0',ADD INDEX ( `sender_canonical_maps` )";
        $q->QUERY_SQL($sql, 'artica_backup');
    }
    $sql = "SELECT * FROM smtp_generic_maps WHERE ou='POSTFIX_MAIN' AND sender_canonical_maps=1 ORDER BY generic_from";
    $results = $q->QUERY_SQL($sql, "artica_backup");
    while ($ligne = @mysql_fetch_array($results, MYSQL_ASSOC)) {
        if (trim($ligne["generic_from"]) == null) {
            continue;
        }
        if (trim($ligne["generic_to"]) == null) {
            continue;
        }
        $GLOBALS["sender_canonical_maps"][] = "{$ligne["generic_from"]}\t{$ligne["generic_to"]}";
    }
}
function users_list()
{
    $tpl = new templates();
    $MyPage = CurrentPageName();
    $ldap = new clladp();
    if ($ldap->IsKerbAuth()) {
        users_list_active_directory();
        return;
    }
    $database = "artica_backup";
    $search = '%';
    $table = "squid_ssl";
    $page = 1;
    $FORCE_FILTER = "AND `type`='ssl-bump-wl'";
    $t = $_GET["t"];
    $sock = new sockets();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if (is_base64_encoded($_GET["ou"])) {
        $ou_encoded = $_GET["ou"];
        $ou = base64_decode($_GET["ou"]);
    } else {
        $ou = $_GET["ou"];
        $ou_encoded = base64_encode($_GET["ou"]);
    }
    if ($_SESSION["uid"] != -100) {
        $ou = $_SESSION["ou"];
    }
    if ($_POST["query"] != null) {
        $tofind = $_POST["query"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    if (!$ldap->IsOUUnderActiveDirectory($ou)) {
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $cc = new ldapAD();
            $hash = $cc->find_users($ou, $tofind);
        } else {
            $ldap = new clladp();
            $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
            $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
        }
    } else {
        $EnableManageUsersTroughActiveDirectory = 1;
        include_once dirname(__FILE__) . "/ressources/class.external.ad.inc";
        $ad = new external_ad_search();
        $hash = $ad->find_users($ou, $tofind);
    }
    $users = new user();
    $number = $hash["count"];
    if (!is_numeric($number)) {
        $number = 0;
    }
    $data = array();
    $data['page'] = 1;
    $data['total'] = $number;
    $data['rows'] = array();
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $uid = $userARR["samaccountname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $img = imgsimple("contact-24.png", null, $js);
        $href = "<a href=\"javascript:blur();\" OnClick=\"javascript:{$js}\" style='text-decoration:underline'>";
        $dele = imgsimple("delete-24.png", null, "Loadjs('domains.delete.user.php?uid={$uid}&flexRT={$t}');");
        $data['rows'][] = array('id' => $uid, 'cell' => array($img, "<span style='font-size:14px;color:{$color}'>{$href}{$userARR["sn"][0]} {$userARR["givenname"][0]}</a><div><i>{$userARR["title"][0]}</i></span>", "<span style='font-size:14px;color:{$color}'>{$userARR["telephonenumber"][0]}</span>", "<span style='font-size:14px;color:{$color}'>{$href}{$userARR["mail"][0]}</a></span>", $dele));
    }
    echo json_encode($data);
}
Esempio n. 26
0
function rebuild_all_mailboxes($ou_encoded)
{
    if (!Build_pid_func(__FILE__, "rebuild_all_mailboxes_{$ou_encoded}")) {
        rebuild_all_mailboxes_events("Already executed", $ou_encoded);
        return;
    }
    $ldap = new clladp();
    $filter = "(&(objectClass=userAccount)(|(cn=*)(mail=*)))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber");
    $dn = "ou=" . base64_decode($ou_encoded) . ",dc=organizations,{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    $number = $hash["count"];
    rebuild_all_mailboxes_events("{$number} user(s) in {$dn}", $ou_encoded);
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        $ct = new user($uid);
        if (strpos($uid, '$') > 0) {
            rebuild_all_mailboxes_events("{$ct->DisplayName} SKIP {computer}=TRUE", $ou_encoded);
            continue;
        }
        if ($ct->MailboxActive != 'TRUE') {
            rebuild_all_mailboxes_events("{$ct->DisplayName} SKIP MailboxActive=FALSE", $ou_encoded);
            continue;
        }
        $cyrus = new cyrus();
        if ($cyrus->MailBoxExists($uid)) {
            rebuild_all_mailboxes_events("[{$number}/{$i}]:: {$uid}: {mailbox_already_exists}", $ou_encoded);
            continue;
        }
        $cyrus->CreateMailbox($uid);
        rebuild_all_mailboxes_events("[{$number}/{$i}]::{$uid}: {$cyrus->cyrus_infos}", $ou_encoded);
    }
    rebuild_all_mailboxes_events("{success}", $ou_encoded);
}
function transport_maps_search()
{
    $ldap = new clladp();
    $filter = "(&(objectClass=transportTable)(cn=*))";
    $attrs = array("cn", "transport");
    $dn = "{$ldap->suffix}";
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $domain = $hash[$i]["cn"][0];
        $transport = $hash[$i]["transport"][0];
        //$transport=str_replace("relay:","smtp:",$transport);
        if (substr($domain, 0, 1) == "@") {
            $domain = substr($domain, 1, strlen($domain));
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps"]["{$domain}"] = "{$transport}";
        }
        if (strpos("  {$domain}", "@") == 0) {
            $domain = "@{$domain}";
        }
        if (!$GLOBALS["transport_mem"]["{$domain}"]) {
            $GLOBALS["transport_maps_AT"]["{$domain}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$domain}"] = true;
    }
    $dn = "cn=artica_smtp_sync,cn=artica,{$ldap->suffix}";
    $filter = "(&(objectClass=InternalRecipients)(cn=*))";
    $attrs = array("cn", "ArticaSMTPSenderTable");
    $hash = $ldap->Ldap_search($dn, $filter, $attrs);
    for ($i = 0; $i < $hash["count"]; $i++) {
        $email = $hash[$i]["cn"][0];
        $transport = $hash[$i][strtolower("ArticaSMTPSenderTable")][0];
        $uid = $ldap->uid_from_email($email);
        if ($uid != null) {
            continue;
        }
        if (!$GLOBALS["transport_mem"]["{$email}"]) {
            $GLOBALS["transport_maps"]["{$email}"] = "{$transport}";
        }
        $GLOBALS["transport_mem"]["{$email}"] = true;
    }
}
Esempio n. 28
0
function SMBCHANGEUSERS()
{
    $ldap = new clladp();
    $filter_search = "(&(objectClass=sambaSamAccount)(cn=*))";
    $attrs = array("uid");
    $dn = "{$ldap->suffix}";
    if (posix_getuid() == 0) {
        echo "{$filter_search} in {$dn}\n";
    }
    $hash = $ldap->Ldap_search($dn, $filter_search, $attrs);
    if ($hash["count"] == null) {
        $hash["count"] = 0;
    }
    if (posix_getuid() == 0) {
        echo "Users={$hash["count"]}\n";
    }
    for ($i = 0; $i < $hash["count"]; $i++) {
        $realuid = $hash[$i]["uid"][0];
        if (strpos("  {$realuid}", '$') > 0) {
            continue;
        }
        $u = new user($realuid);
        if (posix_getuid() == 0) {
            echo "Update {$realuid} {$u->dn}\n";
        }
        $tpl = new templates();
        if (posix_getuid() != 0) {
            echo "{edit}:{$u->DisplayName}\n";
        }
        $u->Samba_edit_user();
    }
}
function organization_users_find_member()
{
    $t = time();
    $html = "\n\t<div id='{$t}'></div>\n\t<script>\n\t\tLoadAjax('{$t}','domains.manage.org.findusers.php?ou={$ou}');\n\t</script>\n\t";
    echo $html;
    return;
    $keycached = "{$_GET["finduser"]}{$_GET["ou"]}";
    if (GET_CACHED(__FILE__, __FUNCTION__, $keycached)) {
        return true;
    }
    $sock = new sockets();
    $tofind = $_GET["finduser"];
    $tpl = new templates();
    $page = CurrentPageName();
    $EnableManageUsersTroughActiveDirectory = $sock->GET_INFO("EnableManageUsersTroughActiveDirectory");
    if (!is_numeric($EnableManageUsersTroughActiveDirectory)) {
        $EnableManageUsersTroughActiveDirectory = 0;
    }
    if (is_base64_encoded($_GET["ou"])) {
        $ou_encoded = $_GET["ou"];
        $ou = base64_decode($_GET["ou"]);
    } else {
        $ou = $_GET["ou"];
        $ou_encoded = base64_encode($_GET["ou"]);
    }
    writelogs("Find users {$tofind} in {$ou} (encoded={$_GET["ou"]}) EnableManageUsersTroughActiveDirectory:{$EnableManageUsersTroughActiveDirectory}", __FUNCTION__, __FILE__, __LINE__);
    if ($_SESSION["uid"] != -100) {
        $ou = $_SESSION["ou"];
    }
    if ($tofind == null) {
        $tofind = '*';
    } else {
        $tofind = "*{$tofind}*";
    }
    $filter = "(&(objectClass=userAccount)(|(cn={$tofind})(mail={$tofind})(displayName={$tofind})(uid={$tofind}) (givenname={$tofind})))";
    $attrs = array("displayName", "uid", "mail", "givenname", "telephoneNumber", "title", "sn", "mozillaSecondEmail", "employeeNumber", "sAMAccountName");
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $cc = new ldapAD();
        $hash = $cc->find_users($ou, $tofind);
    } else {
        $ldap = new clladp();
        $dn = "ou={$ou},dc=organizations,{$ldap->suffix}";
        $hash = $ldap->Ldap_search($dn, $filter, $attrs, 150);
    }
    $users = new user();
    $number = $hash["count"];
    if (!is_numeric($number)) {
        $number = 0;
    }
    $bg = "#FFFFFF";
    writelogs("Find users {$tofind} in ou {$ou} DN:\"{$dn}\" (encoded={$_GET["ou"]}) {$number} items", __FUNCTION__, __FILE__, __LINE__);
    $html = "\n\t\n\t\n\t<table style='width:100%'>\n\t<tr>\n\t\t<td valign='top'>\n\t\t<div style='width:100%;height:560px;overflow:auto'>\t\n\t\t<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:100%'>\n\t\t<thead class='thead'>\n\t\t\t<tr>\n\t\t\t\t<th colspan=4>{$tofind}</th>\n\t\t\t</tr>\n\t\t</thead>\n\t\t<tbody class='tbody'>\n\t\t\t\t\n\t";
    $add_user_disabled = Paragraphe('folder-useradd-64-grey.png', '{create_user}', '{create_user_text}');
    $add_user = Paragraphe('folder-useradd-64.png', '{create_user}', '{create_user_text}', "javascript:Loadjs('domains.add.user.php?ou={$ou}')", null, 210, null, 0, true);
    $groups = Paragraphe('folder-group-64.png', '{manage_groups}', '{manage_groups_text}', "javascript:Loadjs('domains.edit.group.php?ou={$ou_encoded}&js=yes')", null, 210, 100, 0, true);
    $delete_all_users = Paragraphe('member-64-delete.png', '{delete_all_users}', '{delete_all_users_text}', "javascript:DeleteAllusers()", null, 210, 100, 0, true);
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $delete_all_users = Paragraphe('member-64-delete-grey.png', '{delete_all_users}', '{delete_all_users_text}', "", null, 210, 100, 0, true);
    }
    $usermenus = new usersMenus();
    if ($usermenus->ARTICA_META_ENABLED) {
        if ($sock->GET_INFO("AllowArticaMetaAddUsers") != 1) {
            $add_user = $add_user_disabled;
        }
    }
    if ($EnableManageUsersTroughActiveDirectory == 1) {
        $add_user = $add_user_disabled;
    }
    $delete_all_users_warn = $tpl->javascript_parse_text("{delete_all_users_warn}");
    for ($i = 0; $i < $number; $i++) {
        $userARR = $hash[$i];
        $uid = $userARR["uid"][0];
        if ($EnableManageUsersTroughActiveDirectory == 1) {
            $uid = $userARR["samaccountname"][0];
        }
        if ($uid == "squidinternalauth") {
            continue;
        }
        $js = MEMBER_JS($uid, 1, 1);
        if ($userARR["sn"][0] == null && $userARR["givenname"][0] == null) {
            $userARR["sn"][0] = $uid;
        }
        $sn = texttooltip($userARR["sn"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $givenname = texttooltip($userARR["givenname"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $title = texttooltip($userARR["title"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $mail = texttooltip($userARR["mail"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        $telephonenumber = texttooltip($userARR["telephonenumber"][0], "{display}:{$uid}", $js, null, 0, "font-size:13px");
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $img = imgtootltip("contact-48.png", "{apply}", $js);
        if ($userARR["telephonenumber"][0] == null) {
            $userARR["telephonenumber"][0] = "&nbsp;";
        }
        if ($userARR["mail"][0] == null) {
            $userARR["mail"][0] = "&nbsp;";
        }
        $html = $html . "<tr class={$classtr}>\n\t\t\t\t\t\t<td width=1% style='font-size:12px'>{$img}</td>\n\t\t\t\t\t\t<td width=50% style='font-size:12px'>{$userARR["sn"][0]} {$userARR["givenname"][0]}<div><i>{$userARR["title"][0]}</i></div></td>\n\t\t\t\t\t\t<td width=1% style='font-size:12px'>{$userARR["telephonenumber"][0]}</td>\n\t\t\t\t\t\t<td width=50% style='font-size:12px' nowrap>{$userARR["mail"][0]}</td>\n\t\t\t\t\t\t</tr>\n\t\t\t\n\t\t";
    }
    $html = $html . "</table>\n\t</div>\n\t</td>\n\t<td valign='top' width=1%>{$add_user}<br>{$groups}<br>{$delete_all_users}</td>\n\t</tr>\n\t</table>\n\t\n\t<script>\n\t\n\tvar X_DeleteAllusers= function (obj) {\n\t\tvar results=trim(obj.responseText);\n\t\tif(results.length>0){alert(results);}\n\t\tLoadAjax('org_user_list','{$page}?finduser=&ou='+escape('{$ou}'));\n\t\t}\t\t\n\n\t\tfunction DeleteAllusers(){\n\t\t\tif(confirm('{$delete_all_users_warn}')){\n\t\t\tvar XHR = new XHRConnection();\n\t\t\tXHR.appendData('DeleteAllUsersInOu','yes');\n\t\t\tXHR.appendData('ou','{$ou}');\n\t\t\tdocument.getElementById('org_user_list').src='img/wait_verybig.gif';   \t\n\t\t\tXHR.sendAndLoad('{$page}', 'GET',X_DeleteAllusers);\n\t\t\t}\n\t\t\n\t\t}\n\t\n</script>\t\n\t";
    $html = $tpl->_ENGINE_parse_body($html);
    SET_CACHED(__FILE__, __FUNCTION__, $keycached, $html);
    echo $html;
}
Esempio n. 30
0
function find_member(){
	$tofind=$_GET["find-member"];
	if($_SESSION["uid"]==-100){$ou=$_GET["ou"];}else{$ou=$_SESSION["ou"];}
	$ldap=new clladp();
	if(is_base64_encoded($ou)){$ou=base64_decode($ou);}
	if($tofind==null){$tofind='*';}else{$tofind="*$tofind*";}
	$tofind=str_replace('***','*',$tofind);
	writelogs("FIND $tofind IN OU \"$ou\"",__FUNCTION__,__FILE__,__LINE__);
	
	$filter="(&(objectClass=userAccount)(|(cn=$tofind)(mail=$tofind)(displayName=$tofind)(uid=$tofind) (givenname=$tofind) ))";
	$attrs=array("displayName","uid","mail","givenname","telephoneNumber","title","sn","mozillaSecondEmail","employeeNumber","sAMAccountName");
	$dn="ou=$ou,dc=organizations,$ldap->suffix";
	
	if($ldap->EnableManageUsersTroughActiveDirectory){
		$cc=new ldapAD();
		$filter="(&(objectClass=user)(|(cn=$tofind)(mail=$tofind)(displayName=$tofind)(sAMAccountName=$tofind) (givenname=$tofind) ))";
		$dn="ou=$ou,$cc->suffix";
		if(trim($ou)=="Domain Controllers"){$dn="CN=Users,$cc->suffix";}
		
	}
	
	$hash=$ldap->Ldap_search($dn,$filter,$attrs,20);
	
	$users=new user();
	
	$number=$hash["count"];
	
	for($i=0;$i<$number;$i++){
		$user=$hash[$i];
		$html=$html .formatUser($user,$ldap->EnableManageUsersTroughActiveDirectory);
		
	}
	return $html;
}