Exemplo n.º 1
0
function popup_connected_search()
{
    $ocs = new ocs();
    $sql = $ocs->COMPUTER_SEARCH_QUERY($_GET["connected-search"]);
    $CONFIG = $ocs->GET_SERVER_SETTINGS();
    $PROLOG_FREQ = $CONFIG["PROLOG_FREQ"] * 60;
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "ocsweb");
    if (!$q->ok) {
        echo "<p>&nbsp;</p><p style='font-size:15px'>{$q->mysql_error}<hr>{$sql}</p>";
        return;
    }
    $html = "\n\t<table style='width:100%;'>\n\t<tr>\n\t\t<th colspan=2>{computer}</th>\n\t\t<th>{status}</th>\n\t\t<th>{ComputerMacAddress}</th>\n\t\t<th>{ip_address}</th>\n\t</tr>";
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["IPADDRESS"] == "0.0.0.0") {
            continue;
        }
        if ($ligne["MACADDR"] == "00:00:00:00:00:00") {
            continue;
        }
        if ($already[$ligne["MACADDR"]]) {
            continue;
        }
        if ($already[$ligne["NAME"] . $ligne["IPSRC"]]) {
            continue;
        }
        $status = null;
        $already[$ligne["MACADDR"]] = true;
        $already[$ligne["NAME"] . $ligne["IPADDRESS"]] = true;
        $f = new computers();
        $uid = $f->ComputerIDFromMAC($ligne["MACADDR"]);
        if (trim($uid) != null) {
            $already[$ligne["NAME"] . $ligne["IPSRC"]] = true;
        }
        $js = MEMBER_JS($uid, 1, 1);
        $last = distanceOfTimeInWords(strtotime($ligne["LASTCOME"]), time());
        $mins = distanceMinStrings($ligne["LASTCOME"]);
        $js_text = "{$ligne["NAME"]}<hr>{last_com}:{$last}<hr>{$ligne["IPADDRESS"]}";
        if ($mins > $PROLOG_FREQ) {
            $status = imgtootltip('status_service_removed.png', $last);
            $js_text = "{$ligne["NAME"]}<hr><span color:red>{last_com}:{$last}</span>";
        } else {
            $status = imgtootltip('status_service_run.png', $last);
        }
        if ($uid == null) {
            $js = null;
            $status = imgtootltip("status_warning.gif", "{ocs_computer_is_not_in_ldap}", "AddComputerFromOCS('{$ligne["MACADDR"]}')", null, md5($ligne["MACADDR"]) . time());
            $js_text = "{ocs_computer_is_not_in_ldap}";
        } else {
        }
        if (trim($ligne["IPADDRESS"]) != null) {
            if (trim($ligne["IPSRC"]) != trim($ligne["IPADDRESS"])) {
                $ligne["IPSRC"] = $ligne["IPSRC"] . "/" . $ligne["IPADDRESS"];
            }
        }
        $html = $html . "\n\t\t<tr " . CellRollOver($js, $js_text) . ">\n\t\t\t<td width=1%><img src='img/laptop-32.png'></td>\n\t\t\t<td style='font-size:13px'>{$ligne["NAME"]}</td>\n\t\t\t<td width=1% align='center' valign='middle'>{$status}</td>\n\t\t\t<td style='font-size:13px'>{$ligne["MACADDR"]}</td>\n\t\t\t<td style='font-size:12px'>{$ligne["IPSRC"]}</td>\n\t\t</tr>\n\t\t\n\t\t";
    }
    $html = $html . "</table>\n\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
Exemplo n.º 2
0
function popup_connected_search()
{
    $ocs = new ocs();
    $sql = $ocs->COMPUTER_SEARCH_QUERY($_GET["connected-search"]);
    $CONFIG = $ocs->GET_SERVER_SETTINGS();
    $PROLOG_FREQ = $CONFIG["PROLOG_FREQ"] * 60;
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "ocsweb");
    if (!$q->ok) {
        echo "<p>&nbsp;</p><p style='font-size:15px'>{$q->mysql_error}<hr>{$sql}</p>";
        return;
    }
    $html = "\n<table cellspacing='0' cellpadding='0' border='0' class='tableView' style='width:99%'>\n<thead class='thead'>\n<tr>\n\t\t<th colspan=2>{computer}</th>\n\t\t<th>{status}</th>\n\t\t<th>{ComputerMacAddress}</th>\n\t\t<th>{ip_address}</th>\n\t</tr>\n</thead>\n<tbody class='tbody'>\t";
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["IPADDRESS"] == "0.0.0.0") {
            continue;
        }
        if ($ligne["MACADDR"] == "00:00:00:00:00:00") {
            continue;
        }
        if ($already[$ligne["MACADDR"]]) {
            continue;
        }
        if ($already[$ligne["NAME"] . $ligne["IPSRC"]]) {
            continue;
        }
        $status = null;
        $already[$ligne["MACADDR"]] = true;
        $already[$ligne["NAME"] . $ligne["IPADDRESS"]] = true;
        $f = new computers();
        $uid = $f->ComputerIDFromMAC($ligne["MACADDR"]);
        if (trim($uid) != null) {
            $already[$ligne["NAME"] . $ligne["IPSRC"]] = true;
        }
        $js = MEMBER_JS($uid, 1, 1);
        $last = distanceOfTimeInWords(strtotime($ligne["LASTCOME"]), time());
        $mins = distanceMinStrings($ligne["LASTCOME"]);
        $js_text = "{$ligne["NAME"]}<hr>{last_com}:{$last}<hr>{$ligne["IPADDRESS"]}/{$ligne["MACADDR"]}";
        if ($mins > $PROLOG_FREQ) {
            $js_text = "{$ligne["NAME"]}<hr><span color:#d32d2d>{last_com}:{$last}</span>";
            $status = imgtootltip('ok32-grey.png', $js_text);
        } else {
            $status = imgtootltip('ok32.png', "{$ligne["IPADDRESS"]}/{$ligne["MACADDR"]}<br>{$last}");
        }
        if ($uid == null) {
            $js = null;
            $status = imgtootltip("warning-panneau-32.png", "{ocs_computer_is_not_in_ldap}", "AddComputerFromOCS('{$ligne["MACADDR"]}')", null, md5($ligne["MACADDR"]) . time());
            $js_text = "{ocs_computer_is_not_in_ldap}";
        } else {
        }
        if (trim($ligne["IPADDRESS"]) != null) {
            if (trim($ligne["IPSRC"]) != null) {
                if (trim($ligne["IPSRC"]) != trim($ligne["IPADDRESS"])) {
                    $ligne["IPSRC"] = $ligne["IPSRC"] . "/" . $ligne["IPADDRESS"];
                }
            } else {
                $ligne["IPSRC"] = $ligne["IPADDRESS"];
            }
        }
        if ($classtr == "oddRow") {
            $classtr = null;
        } else {
            $classtr = "oddRow";
        }
        $html = $html . "\n\t\t<tr class={$classtr}>\n\t\t\t<td width=1%>" . imgtootltip("laptop-32.png", $js_text, $js) . "</td>\n\t\t\t<td style='font-size:14px'><code style='font-size:14px'>{$ligne["NAME"]}</code></td>\n\t\t\t<td width=1% align='center' valign='middle'>{$status}</td>\n\t\t\t<td style='font-size:14px'><code style='font-size:14px'>{$ligne["MACADDR"]}</code></td>\n\t\t\t<td style='font-size:14px'><code style='font-size:14px'>{$ligne["IPSRC"]}</code></td>\n\t\t</tr>\n\t\t\n\t\t";
    }
    $html = $html . "</table>\n\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}