コード例 #1
0
function search()
{
    $ocs = new ocs();
    $page = CurrentPageName();
    $sql = $ocs->COMPUTER_SEARCH_QUERY($_GET["search"]);
    $q = new mysql();
    $FILEID = $_GET["FILEID"];
    $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>{ip_address}</th>\n\t\t<th>{affected}</th>\n\t</tr>";
    $hash = $ocs->PACKAGE_HASH_AFFECTED_COMPUTERS($FILEID);
    while ($ligne = mysql_fetch_array($results, MYSQL_ASSOC)) {
        if ($ligne["IPADDRESS"] == "0.0.0.0") {
            continue;
        }
        $HARDWARE_ID = $ligne["ID"];
        $html = $html . "\n\t\t<tr " . CellRollOver() . ">\n\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 style='font-size:13px'>{$ligne["IPSRC"]}</td>\n\t\t\t<td>" . Field_checkbox("ID_{$HARDWARE_ID}", 1, $hash[$HARDWARE_ID], "OCSPackageAffectID({$HARDWARE_ID})") . "</td>\n\t\t</tr>\n\t\t";
    }
    $html = $html . "</table>\n\t<script>\n\t\tvar x_OCSPackageAffectID=function (obj) {\n\t\t\tvar results=obj.responseText;\n\t\t\tif (results.length>0){\n\t\t\t\talert(results);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif(document.getElementById('packages-list')){\n\t\t\t\tRefreshOCSPackageList();\n\t\t\t}\n\t\t}\n\t\t\n\t\tfunction OCSPackageAffectID(HARDWARE_ID){\n\t\t\t\tvar XHR = new XHRConnection();\n\t\t\t\tif(document.getElementById('ID_'+HARDWARE_ID).checked){\n\t\t\t\t\tXHR.appendData('AffectPackageToValue','1');\n\t\t\t\t}else{\n\t\t\t\t\tXHR.appendData('AffectPackageToValue','0');\n\t\t\t\t}\n\t\t\t\tXHR.appendData('FILEID','{$FILEID}');\n\t\t\t\tXHR.appendData('HARDWARE_ID',HARDWARE_ID);\n\t\t\t\tXHR.sendAndLoad('{$page}', 'GET',x_OCSPackageAffectID);\n\t\t}\t\n\t\n\t</script>\n\t\n\t\n\t";
    $tpl = new templates();
    echo $tpl->_ENGINE_parse_body($html);
}
コード例 #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\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);
}
コード例 #3
0
ファイル: ocs.ng.php プロジェクト: BillTheBest/1.6.x
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);
}
コード例 #4
0
function AutomaticInjection()
{
    $users = new usersMenus();
    if (!$users->OCSI_INSTALLED) {
        return;
    }
    $file = "/etc/artica-postfix/cron.2/AutomaticInjection.pid";
    $sock = new sockets();
    $OCSImportToLdap = $sock->GET_INFO("OCSImportToLdap");
    if ($OCSImportToLdap == null) {
        $OCSImportToLdap = 60;
    }
    if ($OCSImportToLdap == 0) {
        return;
    }
    if (!$GLOBALS["FORCE"]) {
        $filetime = file_time_min($file);
        if ($GLOBALS["VERBOSE"]) {
            echo "{$file}={$filetime} against {$OCSImportToLdap} minutes\n";
        }
        if (!$GLOBALS["VERBOSE"]) {
            if ($filetime < $OCSImportToLdap) {
                return;
            }
        }
    }
    writelogs("Starting OCS injection from OCS database", __FUNCTION__, __FILE__, __LINE__);
    $ocs = new ocs();
    $sql = $ocs->COMPUTER_SEARCH_QUERY(null, 1);
    if ($GLOBALS["VERBOSE"]) {
        echo $sql . "\n";
    }
    $q = new mysql();
    $results = $q->QUERY_SQL($sql, "ocsweb");
    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;
        }
        $already[$ligne["MACADDR"]] = true;
        $f = new computers();
        $uid = $f->ComputerIDFromMAC($ligne["MACADDR"]);
        if ($GLOBALS["VERBOSE"]) {
            echo "Check {$ligne["MACADDR"]} against {$uid}\n";
        }
        if ($uid == null) {
            writelogs("uid is null for {$ligne["MACADDR"]}, add it into LDAP", __FUNCTION__, __FILE__, __LINE__);
            AutomaticInjectionAdd($ligne["MACADDR"]);
            continue;
        }
        $update = false;
        $f = new computers($uid);
        if ($GLOBALS["VERBOSE"]) {
            echo "Checking uid={$uid} NAME={$f->ComputerRealName}; IP={$f->ComputerIP}; OS={$f->ComputerOS}\n";
        }
        $ComputerIP = trim($f->ComputerIP);
        $ComputerOS = trim($f->ComputerOS);
        $OSNAME = trim(utf8_encode($ligne["OSNAME"]));
        $PROCESSORT = trim($ligne["PROCESSORT"]);
        if ($GLOBALS["VERBOSE"]) {
            echo "OCS SOURCE {$ligne["MACADDR"]} IP={$ligne["IPSRC"]}; OS={$OSNAME} CPU={$PROCESSORT}\n";
        }
        if ($ComputerIP != $ligne["IPSRC"]) {
            $f->ComputerIP = $ligne["IPSRC"];
            if ($GLOBALS["VERBOSE"]) {
                echo "IPSRC not match ({$ComputerIP})\n";
            }
            $update = true;
        }
        if ($PROCESSORT != null) {
            if (trim($f->ComputerCPU) != $ligne["PROCESSORT"]) {
                if ($GLOBALS["VERBOSE"]) {
                    echo "PROCESSORT not match\n";
                }
                $f->ComputerOS = $ligne["PROCESSORT"];
                $update = true;
            }
        }
        if ($update) {
            echo "update {$ligne["MACADDR"]}\n";
            $f->Add();
        }
    }
    @unlink($file);
    @file_put_contents($file, getmypid());
    writelogs("Finish OCS injection from OCS database", __FUNCTION__, __FILE__, __LINE__);
}