function list_reports($type, $value, $sortby, $sortdir, $widget_mode) { global $allres, $roffset, $pageSize, $dbconn; global $user, $arruser; $dbconn->SetFetchMode(ADODB_FETCH_BOTH); $filteredView = FALSE; $selRadio = array("", "", "", ""); $query_onlyuser = ""; $url_filter = ""; if (!empty($arruser)) { $query_onlyuser = "******"; } if (!empty($sortby)) { $or_sortby = $sortby; } else { $or_sortby = ""; } if (!empty($sortdir)) { $or_sortdir = $sortdir; } else { $or_sortdir = ""; } if ($sortby == "jobname") { $sortby = "t2.name"; } else { if ($sortby == "profile") { $sortby = "t3.name"; } } if ($sortby == "") { $sortby = "scantime"; } if ($sortdir == "" && !preg_match("/(ASC|DESC)\$/i", $sortby)) { $sortdir = "DESC"; } $queryw = ""; $queryl = ""; $leftjoin = ""; if ($type == "net") { $leftjoin = "LEFT JOIN vuln_nessus_results t5 ON t5.report_id=t1.report_id"; } $querys = "SELECT distinct t1.sid as sid, t1.report_id, t4.name as jobname, t4.scan_submit, t4.meth_target, t1.scantime,\n t1.username, t1.scantype, t1.report_key, t1.report_type as report_type, t3.name as profile, t4.id as jobid, t4.meth_SCHED, t1.name as report_name\n FROM vuln_nessus_reports t1\n LEFT JOIN vuln_jobs t2 ON t1.report_id=t2.report_id\n LEFT JOIN vuln_nessus_settings t3 ON t1.sid=t3.id\n LEFT JOIN vuln_jobs t4 on t1.report_id = t4.report_id {$leftjoin}\n WHERE t1.deleted = '0' AND t1.scantime IS NOT NULL "; //Set up the SQL query based on the search form input (if any) switch ($type) { case "scantime": $selRadio[0] = "CHECKED"; $utc_data = Util::get_utc_from_date($dbconn, $value, Util::get_timezone()); $q = $utc_data[6]; $q = str_replace("-", "", $q); $q = str_replace(":", "", $q); $q = str_replace(" ", "", $q); $queryw = " AND t1.scantime LIKE '%{$q}%' {$query_onlyuser} order by {$sortby} {$sortdir}"; $queryl = " limit {$roffset},{$pageSize}"; $stext = "<b>" . _("Search for Date/Time") . "</b> = '*{$value}*'"; $url_filter = "&type={$type}&value={$value}"; break; case "jobname": $selRadio[1] = "CHECKED"; $q = strtolower($value); $queryw = " AND t1.name LIKE '%{$q}%' {$query_onlyuser} order by {$sortby} {$sortdir}"; $queryl = " limit {$roffset},{$pageSize}"; $stext = "<b>" . _("Search for Job Name") . "</b> = '*" . html_entity_decode($q) . "*'"; $url_filter = "&type={$type}&value={$value}"; break; case "fk_name": $selRadio[2] = "CHECKED"; $q = strtolower($value); $queryw = " AND t1.fk_name LIKE '%{$q}%' {$query_onlyuser} order by {$sortby} {$sortdir}"; $queryl = " limit {$roffset},{$pageSize}"; $stext = _("Search for Subnet/CIDR") . " = '*{$q}*'"; $url_filter = "&type={$type}&value={$value}"; break; case "username": $selRadio[3] = "CHECKED"; $q = strtolower($value); $queryw = " AND t1.username LIKE '%{$q}%' {$query_onlyuser} order by {$sortby} {$sortdir}"; $queryl = " limit {$roffset},{$pageSize}"; $stext = "<b>" . _("Search for user") . "</b> = '*{$q}*'"; $url_filter = "&type={$type}&value={$value}"; break; case "net": $selRadio[4] = "CHECKED"; if (!preg_match("/\\//", $value)) { $q = $value; } else { $tokens = explode("/", $value); $bytes = explode(".", $tokens[0]); if ($tokens[1] == "24") { $q = $bytes[0] . "." . $bytes[1] . "." . $bytes[2] . "."; } else { if ($tokens[1] == "16") { $q = $bytes[0] . "." . $bytes[1] . "."; } else { if ($tokens[1] == "8") { $q = $bytes[0] . "."; } else { if ((int) $tokens[1] > 24) { $q = $bytes[0] . "." . $bytes[1] . "." . $bytes[2] . "." . $bytes[3]; } } } } } $queryw = " AND (t4.meth_TARGET LIKE '%{$q}%' OR t5.hostIP LIKE '%{$q}%') {$query_onlyuser} order by {$sortby} {$sortdir}"; $queryl = " limit {$roffset},{$pageSize}"; if (!preg_match("/\\//", $value)) { $stext = "<b>" . _("Search for Host") . "</b> = '*" . html_entity_decode($q) . "*'"; } else { $stext = "<b>" . _("Search for Subnet/CIDR") . "</b> = '*{$q}*'"; } $url_filter = "&type={$type}&value={$value}"; break; default: $selRadio[1] = "CHECKED"; $viewAll = FALSE; $queryw = "{$query_onlyuser} order by {$sortby} {$sortdir}"; $queryl = " limit {$roffset},{$pageSize}"; $stext = ""; break; } $reportCount = 0; if (!$filteredView) { $queryc = "SELECT count(t1.report_id)\n FROM vuln_nessus_reports t1 LEFT JOIN vuln_jobs t2 on t1.report_id = t2.report_id\n LEFT JOIN vuln_nessus_settings t3 ON t1.sid=t3.id\n WHERE t1.deleted = '0'"; $reportCount = $dbconn->GetOne($queryc . $queryw); $previous = $roffset - $pageSize; if ($previous < 0) { $previous = 0; } $last = intval($reportCount / $pageSize) * $pageSize; if ($last < 0) { $last = 0; } $next = $roffset + $pageSize; $pageEnd = $roffset + $pageSize; $value = html_entity_decode($value); $w_val = intval($widget_mode); //echo "<center><table cellspacing=\"0\" cellpadding=\"0\" border=\"0\" width=\"100%\"><tr><td class=\"headerpr\" style=\"border:0;\">"._("Reports")."</td></tr></table></center>"; // output the search form echo "<table cellspacing='0' cellpadding='0' class='w100 transparent'>"; echo "<tr><td class='sec_title'>" . _("Scan Reports Details") . "</td></tr>"; echo "<tr><td style='padding-top:12px;' class='transparent'>"; echo ' <center> <form name="hostSearch" action="index.php" method="GET"> <input type="hidden" name="widget_mode" value="' . $w_val . '"> <input type="text" length="25" name="rvalue" id="rvalue" value="' . Util::htmlentities($value) . '">'; echo "\n<input type=\"radio\" name=\"type\" value=\"scantime\" {$selRadio['0']}>" . _("Date") . "/" . _("Time") . "\n<input type=\"radio\" name=\"type\" value=\"jobname\" {$selRadio['1']}>" . _("Job Name") . "\n<input type=\"radio\" name=\"type\" value=\"net\" {$selRadio['4']}>" . _("Host") . "/" . _("Net") . "\n"; echo <<<EOT <input type="hidden" name="sortby" value="{$sortby}"> <input type="hidden" name="allres" value="{$allres}"> <input type="hidden" name="op" value="search"> EOT; echo "<input type=\"submit\" name=\"submit\" value=\"" . _("Find") . "\" id=\"reports_find_button\" class=\"av_b_secondary small\">"; echo <<<EOT </form> </center> </p> EOT; } else { // get the search result count $queryc = "SELECT count( report_id ) FROM vuln_nessus_reports WHERE t1.deleted = '0' "; $scount = $dbconn->GetOne($queryc . $queryw); echo "<p>{$scount} report"; if ($scount != 1) { echo "s"; } else { } echo " " . _("found matching search criteria") . " | "; echo " <a href='index.php' alt='" . _("View All Reports") . "'>" . _("View All Reports") . "</a></p>"; } echo "<p>"; echo $stext; echo "</p>"; echo "</td></tr></table>"; // get the hosts to display //print_r($querys.$queryw.$queryl); $result = $dbconn->GetArray($querys . $queryw . $queryl); if ($result === false) { $errMsg[] = _("Error getting results") . ": " . $dbconn->ErrorMsg(); $error++; dispSQLError($errMsg, $error); } else { $tdata = array(); foreach ($result as $data) { $data['vSerious'] = 0; $data['vHigh'] = 0; $data['vMed'] = 0; $data['vLow'] = 0; $data['vInfo'] = 0; $vulns_in_report = false; // query for reports for each IP $perms_where = Asset_host::get_perms_where('host.', TRUE); if (!empty($perms_where)) { $query_risk = "SELECT count(lr.risk) as count, lr.risk, lr.hostIP, lr.ctx\n FROM vuln_nessus_results lr, host, host_ip hi\n WHERE host.id=hi.host_id AND inet6_ntoa(hi.ip)=lr.hostIP {$perms_where} AND report_id in (?) AND falsepositive='N'\n GROUP BY lr.risk, lr.hostIP, lr.ctx"; } else { $query_risk = "SELECT count(lr.risk) as count, lr.risk, lr.hostIP, lr.ctx\n FROM vuln_nessus_results lr\n WHERE report_id in (?) AND falsepositive='N'\n GROUP BY lr.risk, lr.hostIP, lr.ctx"; } $result_risk = $dbconn->Execute($query_risk, array($data['report_id'])); while (!$result_risk->EOF) { $vulns_in_report = TRUE; if ($result_risk->fields["risk"] == 7) { $data['vInfo'] += $result_risk->fields['count']; } else { if ($result_risk->fields["risk"] == 6) { $data['vLow'] += $result_risk->fields['count']; } else { if ($result_risk->fields["risk"] == 3) { $data['vMed'] += $result_risk->fields['count']; } else { if ($result_risk->fields["risk"] == 2) { $data['vHigh'] += $result_risk->fields['count']; } else { if ($result_risk->fields["risk"] == 1) { $data['vSerious'] += $result_risk->fields['count']; } } } } } $result_risk->MoveNext(); } $data['clink'] = "respdfc.php?scantime=" . $data['scantime'] . "&scantype=" . $data['scantype'] . "&key=" . $data['report_key'] . $more; $data['plink'] = "respdf.php?scantime=" . $data['scantime'] . "&scantype=" . $data['scantype'] . "&key=" . $data['report_key'] . $more; $data['hlink'] = "reshtml.php?disp=html&output=full&scantime=" . $data['scantime'] . "&scantype=" . $data['scantype'] . $more; $data['rerun'] = "sched.php?action=rerun_scan&job_id=" . $data['jobid'] . $more; $data['xlink'] = "rescsv.php?scantime=" . $data['scantime'] . "&scantype=" . $data['scantype'] . "&key=" . $data['report_key'] . $more; $data['xbase'] = "restextsummary.php?scantime=" . $data['scantime'] . "&scantype=" . $data['scantype'] . $more . "&key=" . $data['report_key']; $list = array(); if ($data["report_type"] == "I") { $perms_where = Asset_host::get_perms_where('host.', TRUE); $dbconn->execute("CREATE TEMPORARY TABLE tmph (id binary(16) NOT NULL,ip varchar(64) NOT NULL,ctx binary(16) NOT NULL, PRIMARY KEY ( id, ip ));"); $dbconn->execute("REPLACE INTO tmph SELECT id, inet6_ntoa(ip), ctx FROM host, host_ip WHERE host.id=host_ip.host_id {$perms_where};"); $result_import = $dbconn->execute("SELECT DISTINCT hostIP, HEX(vuln_nessus_results.ctx) as ctx, hex(id) as host_id FROM vuln_nessus_results LEFT JOIN tmph ON tmph.ctx=vuln_nessus_results.ctx AND hostIP=tmph.ip WHERE report_id = " . $data['report_id']); while (!$result_import->EOF) { if (valid_hex32($result_import->fields["host_id"])) { $list[] = $result_import->fields["host_id"] . "#" . $result_import->fields["hostIP"]; } else { $list[] = $result_import->fields["hostIP"]; } $result_import->MoveNext(); } $dbconn->execute("DROP TABLE tmph;"); } else { $list = explode("\n", trim($data['meth_target'])); } //var_dump($list); if (count($list) == 1) { $list[0] = trim($list[0]); $asset = resolve_asset($dbconn, $list[0], true); $data['target'] = "<span class='tip' title='" . clean_id($list[0]) . "'>" . $asset . "</span>"; } elseif (count($list) == 2) { $list[0] = trim($list[0]); $asset = resolve_asset($dbconn, $list[0], true); $list[0] = "<span class='tip' title='" . clean_id($list[0]) . "'>" . $asset . "</span>"; $list[1] = trim($list[1]); $asset = resolve_asset($dbconn, $list[1], true); $list[1] = "<span class='tip' title='" . clean_id($list[1]) . "'>" . $asset . "</span>"; $data['target'] = $list[0] . ', ' . $list[1]; } else { $list[0] = trim($list[0]); $asset = resolve_asset($dbconn, $list[0], true); $list[0] = "<span class='tip' title='" . clean_id($list[0]) . "'>" . $asset . "</span>"; $list[count($list) - 1] = trim($list[count($list) - 1]); $asset = resolve_asset($dbconn, $list[count($list) - 1], true); $list[count($list) - 1] = "<span class='tip' title='" . clean_id($list[count($list) - 1]) . "'>" . $asset . "</span>"; $data['target'] = $list[0] . " ... " . $list[count($list) - 1]; } if ($data["report_type"] == "I") { $data["jobname"] = $data["report_name"]; } if ($data['vSerious'] == 0 && $data['vHigh'] == 0 && $data['vMed'] == 0 && $data['vLow'] == 0 && $data['vInfo'] == 0 && $vulns_in_report) { $data['vSerious'] = "-"; $data['vHigh'] = "-"; $data['vMed'] = "-"; $data['vLow'] = "-"; $data['vInfo'] = "-"; } $data['target'] = preg_replace("/[0-9a-f]{32}#/i", "", $data['target']); $tdata[] = $data; } if ($sortdir == "ASC") { $sortdir = "DESC"; } else { $sortdir = "ASC"; } $url = $_SERVER['SCRIPT_NAME'] . "?offset=0&sortby=%var%&sortdir={$sortdir}" . $url_filter; $fieldMapLinks = array(); $fieldMapLinks = array(gettext("HTML Results") => array('url' => '%param%', 'param' => 'hlink', 'target' => 'main', 'icon' => 'images/html.png'), gettext("PDF Results") => array('url' => '%param%', 'param' => 'plink', 'target' => '_blank', 'icon' => 'images/pdf.png'), gettext("EXCEL Results") => array('url' => '%param%', 'param' => 'xlink', 'target' => '_blank', 'icon' => 'images/page_white_excel.png')); $fieldMap = array("Date/Time" => array('var' => 'scantime', 'link' => $url), "Job Name" => array('var' => 'jobname', 'link' => $url), "Targets" => array('var' => 'target', 'link' => $url), "Profile" => array('var' => 'profile', 'link' => $url), "Serious" => array('var' => 'vSerious', 'link' => $url), "High" => array('var' => 'vHigh', 'link' => $url), "Medium" => array('var' => 'vMed', 'link' => $url), "Low" => array('var' => 'vLow', 'link' => $url), "Info" => array('var' => 'vInfo', 'link' => $url), "Links" => $fieldMapLinks); if (count($tdata) > 0) { drawTable($fieldMap, $tdata, "Hosts", get_hosts($dbconn)); } else { ?> <table class="table_list"> <tr><td class="nobborder" style="text-align:center;padding: 8px 0px 0px 0px;"><strong><?php echo _("No reports found"); ?> </strong><br/><br/></td></tr> </table> <?php } } // draw the pager again, if viewing all hosts if ($last != 0) { ?> <div class="fright tmargin"> <?php if ($next > $pageSize) { ?> <a href="index.php?sreport=1&<?php echo "sortdir={$or_sortdir}&roffset={$previous}&sortby={$or_sortby}{$url_filter}"; ?> " class="pager">< <?php echo _("PREVIOUS"); ?> </a> <?php } else { ?> <a class='link_paginate_disabled' href="" onclick='return false'>< <?php echo _("PREVIOUS"); ?> </a> <?php } if ($next <= $last) { ?> <a class='lmargin' href="index.php?sreport=1&<?php echo "sortdir={$or_sortdir}&roffset={$next}&sortby={$or_sortby}{$url_filter}"; ?> "> <?php echo _("NEXT"); ?> ></a> <?php } else { ?> <a class='link_paginate_disabled lmargin' href="" onclick='return false'><?php echo _("NEXT"); ?> ></a> <?php } ?> </div> <?php } else { echo "<p> </p>"; } }
include '../standard_header.inc.php'; # 3. Dateiname und evtl. Pfad des Templates für die Webseite $webseite = "ip_rechner.dwt"; include 'computers_header.inc.php'; ############################################################################# $mnr = 1; $sbmnr = -1; $mcnr = -1; # Menuleiste erstellen createMainMenu($rollen, $mainnr); createComputersMenu($rollen, $mnr, $auDN, $sbmnr, $mcnr); ############################################################################# $sort = "hostname"; $sort = $_GET['sort']; $template->assign(array("IP" => "", "OLDIP" => "", "DHCPCONT" => "", "RBSCONT" => "", "DNSCONT" => "", "FIXADD" => "", "HOSTNAME" => "Noch keine Rechner angelegt", "HOSTDN" => "")); $host_array = get_hosts($auDN, array("dn", "hostname", "hwaddress", "ipaddress", "dhcphlpcont", "dhcpoptfixed-address", "hlprbservice"), $sort); # print_r ($host_array); if ($sort == "ipaddress") { $host_array = array_natsort($host_array, "ipaddress", "ipaddress"); } $template->define_dynamic("Hosts", "Webseite"); $i = 0; foreach ($host_array as $host) { $hostip = explode('_', $host['ipaddress']); $fixadd = ""; if ($host['hwaddress']) { if ($host['ipaddress']) { if (count($host['dhcphlpcont']) != 0 && $host['dhcpoptfixed-address'] == "ip") { $dhcp_radio = "\n\t\t\t\t\t<input type='radio' name='dhcp[{$i}]' value='fix' checked> fix \t\t\t\n\t\t\t\t\t<input type='radio' name='dhcp[{$i}]' value=''> kein <br>\n\t\t\t\t\t<input type='radio' name='dhcp[{$i}]' value='fixdns'> fix DNS\n\t\t\t\t\t<input type='hidden' name='olddhcp[]' value='fix'>"; $fixadd = $host['dhcpoptfixed-address']; } elseif (count($host['dhcphlpcont']) != 0 && $host['dhcpoptfixed-address'] == "hostname") {
$array[$key] = $val + array('debug' => 'true', 'is_wp' => 'true'); } else { $array[$key] = $val + array('debug' => 'true', 'is_wp' => 'false'); } } else { if (array_key_exists($key, $wp)) { $array[$key] = $val + array('debug' => 'false', 'is_wp' => 'true'); } else { $array[$key] = $val + array('debug' => 'false', 'is_wp' => 'false'); } } } $array['site_count'] = count($hosts); return $array; } $hosts = get_hosts($path); ?> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>Varying Vagrant Vagrants Dashboard</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link rel="stylesheet" type="text/css" href="style.css?ver=5" /> <script type="text/JavaScript" src="bower_components/jquery/dist/jquery.min.js"></script> <script type="text/javascript" src="src/js/scripts.js"></script> </head> <body> <div class="navbar navbar-inverse navbar-fixed-top" role="navigation"> <div class="container">
} } else { $template->assign(array("ALTRBSDN" => "", "ALTRBSCN" => "", "ALTRBSAU" => "")); } ################################################ # Bootmenü Einträge $menuentries = get_menuentries($pxeDN, array("dn", "menuposition", "label", "menulabel")); #print_r($menuentries); echo "<br>"; $template->define_dynamic("Bootmenu", "Webseite"); foreach ($menuentries as $me) { $template->assign(array("MENDN" => $me['dn'], "MENULABEL" => $me['menulabel'], "POSITION" => $me['menuposition'], "AUDN" => $auDN)); $template->parse("BOOTMENU_LIST", ".Bootmenu"); } ################################################ # PXE kopieren $hostorgroup = $exp[0]; $hgexp = explode('=', $exp[0]); $hosts_array = get_hosts($auDN, array("dn", "hostname")); $groups_array = get_groups($auDN, array("dn", "cn")); $template->define_dynamic("Hosts", "Webseite"); foreach ($hosts_array as $item) { $template->assign(array("HDN" => $item['dn'], "HN" => $item['hostname'])); $template->parse("HOSTS_LIST", ".Hosts"); } $template->define_dynamic("Groups", "Webseite"); foreach ($groups_array as $item) { $template->assign(array("GDN" => $item['dn'], "GN" => $item['cn'])); $template->parse("GROUPS_LIST", ".Groups"); } ################################################################################### include "computers_footer.inc.php";
/** * objects_to_adjust($newmipb,$delip,$childauDN,$cchild_array) * Liefert die durch eine Reduzierung einer IP Delegierung betroffenen Host/DHCP-Objekte der Child-AU * und Child-Child-AUs in einem Array. Dieses enthaelt fuer jedes Objekt dessen Distinguished Name, * dessen IP Adresse(n)/Range(s) und den Distinguished Name der AU der das Objekt angehoert. Parameter * die fuer die Funktionen delete_ip_host(), delete_ip_dhcprange(), modify_ip_dhcprange() benoetigt werden. * * @param string newmipb IP Bereich der nach Reduzierung verbleibt * @param string delip IP Bereich der durch Reduzierung wegfaellt * @param string childauDN Distinguished Name des untergeordneten (Child) LDAP AU-Objektes * @param array cchild_array Array von allen Child-Child-AUs (jedes Item enthaelt DN und MaxIPBlock) * * @return array objects_to_adjust Array aller betroffenen Objekte (DN, IP, auDN) * * @author Tarik Gasmi */ function objects_to_adjust($newmipb, $delip, $childauDN, $cchild_array) { global $ds, $suffix, $ldapError; # Hosts von child-AU, child-child-AU $chosts = get_hosts($childauDN, array("dn", "ipaddress")); # print_r($chosts);printf("<br><br>"); $cchosts = array(); foreach ($cchild_array as $item) { $cchostsitem = get_hosts($item['dn'], array("dn", "ipaddress")); foreach ($cchostsitem as $item2) { $cchosts[] = $item2; } } $chosts = array_merge($chosts, $cchosts); # print_r($chosts);printf("<br><br>"); # Pools von child-AU, child-child-AU $csubnets = get_dhcppools($childauDN, array("dn", "dhcprange")); # print_r($csubnets);printf("<br><br>"); $ccsubnets = array(); foreach ($cchild_array as $item) { $ccsubnetsitem = get_hosts($item['dn'], array("dn", "dhcprange")); foreach ($ccsubnetsitem as $item2) { $ccsubnets[] = $item2; } } $csubnets = array_merge($csubnets, $ccsubnets); # print_r($csubnets);printf("<br><br>"); # Zu loeschende Hosts bestimmen $chosts_todo = array(); foreach ($delip as $delipitem) { if (count($chosts) != 0) { foreach ($chosts as $item) { if (count($item['ipaddress']) > 1) { foreach ($item['ipaddress'] as $item2) { if (intersect_ipranges($delipitem, $item2) != false) { $chosts_todo[] = array('dn' => $item['dn'], 'ip' => $item['ipaddress'], 'auDN' => $item['auDN']); } } } elseif (count($item['ipaddress']) == 1) { if (intersect_ipranges($delipitem, $item['ipaddress']) != false) { $chosts_todo[] = array('dn' => $item['dn'], 'ip' => $item['ipaddress'], 'auDN' => $item['auDN']); } } } } } # print_r($chosts_todo);printf("<br><br>"); # Zu loeschende Subnets bestimmen, und wie IP Range anzupassen ist $csubnets_todo = array(); foreach ($delip as $delipitem) { if (count($csubnets) != 0) { foreach ($csubnets as $item) { if (count($item['dhcprange']) > 1) { foreach ($item['dhcprange'] as $item2) { # print_r(intersect_ipranges($delipitem,$item2)); if (intersect_ipranges($delipitem, $item2) != false) { $csubnets_todo[] = array('dn' => $item['dn'], 'newrange' => intersect_ipranges($newmipb, $item2), 'auDN' => $item['auDN']); } } } elseif (count($item['dhcprange']) == 1) { # print_r(intersect_ipranges($delipitem,$item['dhcprange'])); if (intersect_ipranges($delipitem, $item['dhcprange']) != false) { $csubnets_todo[] = array('dn' => $item['dn'], 'newrange' => intersect_ipranges($newmipb, $item['dhcprange']), 'auDN' => $item['auDN']); } } } } } # print_r($csubnets_todo);printf("<br><br>"); $objects_to_adjust = array('hostips' => $chosts_todo, 'dhcpranges' => $csubnets_todo); return $objects_to_adjust; }
function createComputersMenu($roles, $mnr, $auDN, $sbmnr) { global $template, $ds, $suffix, $START_PATH; # Struktur der Registerkartenleiste # Hauptmenu $hauptmenu = array(array("link" => "computers.php", "text" => "Übersicht", "zugriff" => "alle"), array("link" => "hostoverview.php", "text" => "Rechner", "zugriff" => array("MainAdmin")), array("link" => "computers.php", "text" => "Neuen Rechner anlegen", "zugriff" => array("MainAdmin")), array("link" => "groupoverview.php", "text" => "Rechnergruppen", "zugriff" => array("MainAdmin")), array("link" => "computers.php", "text" => "Neue Gruppe anlegen", "zugriff" => array("MainAdmin"))); # Submenu $computers_array = get_hosts($auDN, array("dn", "hostname", "ou")); for ($n = 0; $n < count($computers_array); $n++) { $comps[] = array("link" => "host.php?dn=" . $computers_array[$n]['dn'] . "&sbmnr=" . $n, "text" => $computers_array[$n]['hostname'], "zugriff" => array("MainAdmin")); } $groups_array = get_groups($auDN, array("dn", "cn")); for ($n = 0; $n < count($groups_array); $n++) { $groups[] = array("link" => "group.php?dn=" . $groups_array[$n]['dn'] . "&sbmnr=" . $n, "text" => $groups_array[$n]['cn'], "zugriff" => array("MainAdmin")); } $submenu = array(array(array()), $comps, array(array()), $groups, array(array())); $rollen = array_keys($roles); # Zusammenstellen der Menuleiste $template->define_dynamic("Hauptmenu", "Menu"); $template->define_dynamic("Submenu", "Menu"); $i = 0; $maxmenu = count($hauptmenu); foreach ($hauptmenu as $item) { $template->clear_parse("SUBMENU_LIST"); if ($item['zugriff'] === "alle" || vergleicheArrays($rollen, $item['zugriff'])) { $subempty = 0; $j = 0; $maxsub = count($submenu[$mnr]); foreach ($submenu[$mnr] as $item2) { if ($item2['zugriff'] === "alle" || vergleicheArrays($rollen, $item2['zugriff'])) { if ($i != $mnr) { $template->assign(array("SUB" => "")); # "LINK_S" => "", # "TEXT_S" => "")); $template->parse("SUBMENU_LIST", ".Submenu"); $template->clear_dynamic("Submenu"); } else { if ($j == 0) { if ($sbmnr == 0) { if ($maxsub == 1) { $zwisch = "branchbottom2"; } else { $zwisch = "branch2"; } $lastaktive = true; $farb = "#505050"; } else { if ($maxsub == 1) { $zwisch = "branchbottom2"; } else { $zwisch = "branch2"; } $farb = "#A0A0A0"; $lastaktive = false; } } else { if ($sbmnr == $j) { if ($maxsub == $j + 1) { $zwisch = "branchbottom2"; } else { $zwisch = "branch2"; } $lastaktive = true; $farb = "#505050"; } else { $farb = "#A0A0A0"; if ($maxsub == $j + 1) { $zwisch = "branchbottom2"; } else { $zwisch = "branch2"; } # if ($lastaktive) {$zwisch="branch";} # else {$zwisch="branch";} $lastaktive = false; } } $htmlcode = "\n\t\t \t\t<tr height='4'>\n\t\t\t\t\t\t<td></td><td align='right'><img src='../pics/line2.gif' height='4'></td><td></td><td></td>\n\t\t \t\t</tr>\n\t\t \t\t<tr>\n\t\t\t\t\t\t<td width='10%'> </td>\n\t\t\t\t\t\t<td width='15%' align='right'><img src='../pics/" . $zwisch . ".gif'></td>\r\n\t\t \t\t\t<td width='65%' align='left' style='border-width:1 1 1 1;border-color:#000000;border-style:solid;padding:5;padding-left:30px;background-color:{FARBE_S}'> \n\t\t \t\t\t<a href='" . $item2['link'] . "' style='text-decoration:none'><b class='standard_schrift'>" . $item2['text'] . "</b></a></td>\n\t\t\t\t\t\t<td width='10%'> </td> \t\t\t\t\t\t\n\t\t\t\t\t</tr>\n\t\t\t\t\t"; $template->assign(array("SUB" => $htmlcode)); $template->assign(array("FARBE_S" => $farb)); $template->parse("SUBMENU_LIST", ".Submenu"); $template->clear_dynamic("Submenu"); } } else { $subempty++; } $j = $j + 1; } if ($subempty == count($submenu[$mnr])) { $template->assign(array("SUB" => "")); # "LINK_S" => "", # "TEXT_S" => "")); $template->parse("SUBMENU_LIST", ".Submenu"); $template->clear_dynamic("Submenu"); } if ($i == 0) { if ($mnr == 0) { if (count($submenu[$i][0]) != 0) { if ($maxmenu == 1) { $zwisch = ""; } else { $zwisch = ""; } } else { $zwisch = ""; } $lastaktive = true; $farb = "#505050"; } else { if (count($submenu[$i][0]) != 0) { if ($maxmenu == 1) { $zwisch = "<a href='{LINK_M}' style='border-style=none;text-decoration:none'>\n \t<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>"; } else { $zwisch = "<a href='{LINK_M}' style='border-style=none;text-decoration:none'>\n \t<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>"; } } else { $zwisch = ""; } $farb = "#A0A0A0"; $lastaktive = false; } } else { if ($mnr == $i) { if (count($submenu[$mnr][0]) != 0) { if ($maxmenu == $i + 1) { $zwisch = ""; } else { $zwisch = ""; } } else { $zwisch = ""; } $lastaktive = true; $farb = "#505050"; } else { $farb = "#A0A0A0"; if (count($submenu[$i][0]) != 0) { if ($maxmenu == $i + 1) { $zwisch = "<a href='{LINK_M}' style='border-style=none;text-decoration:none'>\n \t<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>"; } else { $zwisch = "<a href='{LINK_M}' style='border-style=none;text-decoration:none'>\n \t<img style='border-width:0;border-style=none;' src='../pics/plus2.gif'></a>"; } } else { $zwisch = ""; } #if ($lastaktive) {$zwisch="";} #else {$zwisch="";} $lastaktive = false; } } $template->assign(array("ICON" => $zwisch, "FARBE" => $farb, "LINK_M" => $item["link"], "TEXT_M" => $item["text"])); $template->parse("HAUPTMENU_LIST", ".Hauptmenu"); $template->clear_dynamic("Hauptmenu"); } $i = $i + 1; } if ($lastaktive) { $template->assign(array("ENDE" => "")); } else { $template->assign(array("ENDE" => "")); } }
# if AU IP Ranges ... DNS Lookup Test $mipbs = get_maxipblocks_au($audn[$i]); #echo "MIPBS: <br>";print_r($mipbs); if ($mipbs[0] != "") { foreach ($mipbs as $mipb) { $exp = explode("_", $mipb); if (!check_iprange_zone($exp[0], $exp[1], $auzone[$i], $expou[0])) { $change_zone = 0; } } } if (in_array($auzone[$i], $oldauzone)) { # Zone existiert bereits $mesg .= "<br>Zone {$auzone[$i]} existiert bereits.<br>"; # eigene Host auf Eindeutigkeit testen in neuer Zone ... $hosts = get_hosts($audn[$i], array("dn", "hostname"), ""); if ($matches = check_hostarray_fqdn2($hosts, $auzone[$i])) { $change_zone = 0; $mesg .= "Folgende Hostnamen sind in der neuen Zone bereits vergeben:<br>"; #$j=1; foreach ($matches as $match) { $mesg .= "<b>{$match}</b><br>"; # hosts löschen? # oder hosts auf neue standardnamen setzen ... #$expou = ldap_explode_dn($audn[$i],1); #$c = 0; #while ( !$c ) { # $newhostname = "$expou[0]_$j"; # if (check_host_fqdn2($newhostname,$auzone[$i]) && check_host_fqdn2($newhostname,$oldauzone[$i])){ # $c = 1; # }
function delete_childau($childDN, $childou, $delmodus) { global $ds, $suffix, $auDN, $domDN, $assocdom, $ldapError; if ($delmodus == "integrate") { # Associated DNS Domain integrieren $childdc = get_domain_data($childDN, array("dn", "associatedname")); print_r($childdc); echo "<br>"; # wenn einzige AU dann einfach in Parentdomain aufnehmen und betroffene Einträge löschen if (count($childdc[0]['associatedname']) == 1) { echo "einzige AU<br>"; # dc Childs verschieben $dcchilds = get_dc_childs($childdc[0]['dn'], array("dn", "dc")); # print_r($dcchilds); echo "<br>"; if (count($dcchilds) != 0) { foreach ($dcchilds as $dcc) { # print_r($dcc['dn']); echo " >> "; print_r("dc=".$dcc['dc'].",".$domDN); echo "<br>"; if (move_subtree($dcc['dn'], "dc=" . $dcc['dc'] . "," . $domDN)) { $newdom = $dcc['dc'] . "." . $assocdom; #print_r($newdom); echo "<br><br>"; dive_into_dctree_adapt("dc=" . $dcc['dc'] . "," . $domDN, $newdom); } } } # alten dc-Knoten löschen dive_into_tree_del($childdc[0]['dn'], ""); } # wenn noch andere AUs in der Domain, dann nur betroffene Einträge entfernen if (count($childdc[0]['associatedname']) > 1) { echo "mehrere AUs<br>"; # ChildAU-Rollen unterhalb dc-Knoten löschen (nur diese)(oder übernehmen: MA zu HA, HA zu HA) $roles = get_roles($childDN); #print_r($roles); echo "<br>"; # was ist wenn rollen nur noch ein member haben ... fehler if (count($roles['MainAdmin']) != 0) { $mainadmins = $roles['MainAdmin']; for ($i = 0; $i < count($mainadmins); $i++) { $entryRoleMain['member'][$i] = $mainadmins[$i]; } #print_r($entryRoleHost); echo "<br>"; $resultMA = ldap_mod_del($ds, "cn=MainAdmin,cn=roles," . $childdc[0]['dn'], $entryRoleMain); } if (count($roles['HostAdmin']) != 0) { $hostadmins = $roles['HostAdmin']; for ($i = 0; $i < count($hostadmins); $i++) { $entryRoleHost['member'][$i] = $hostadmins[$i]; } #print_r($entryRoleHost); echo "<br>"; $resultHA = ldap_mod_del($ds, "cn=HostAdmin,cn=roles," . $childdc[0]['dn'], $entryRoleHost); } if (count($roles['ZoneAdmin']) != 0) { $zoneadmins = $roles['ZoneAdmin']; for ($i = 0; $i < count($zoneadmins); $i++) { $entryRoleZone['member'][$i] = $zoneadmins[$i]; } $resultZA = ldap_mod_del($ds, "cn=ZoneAdmin,cn=roles," . $childdc[0]['dn'], $entryRoleZone); } $entrydel['associatedname'] = $childDN; # print_r($entrydel); echo "<br>"; ldap_mod_del($ds, $childdc[0]['dn'], $entrydel); $zentries = get_zone_entries_assocname($childdc[0]['dn'], array("dn"), $childDN); # print_r($zentries); echo "<br>"; foreach ($zentries as $ze) { # print_r($ze['dn']); echo "<br>"; ldap_delete($ds, $ze['dn']); } } # Rechner (mit IP) + dranhängende MCs, PXEs verschieben $hosts = get_hosts($childDN, array("dn", "hostname")); if (count($hosts) != 0) { foreach ($hosts as $host) { # print_r($host['dn']); echo "<br>"; # print_r($host['hostname']); echo "<br>"; # print_r("hostname=".$host['hostname']."-int-".$childou.",cn=computers,".$auDN); echo "<br><br>"; if (move_subtree($host['dn'], "hostname=" . $host['hostname'] . "-ex-" . $childou . ",cn=computers," . $auDN)) { $newhostDN = "hostname=" . $host['hostname'] . "-ex-" . $childou . ",cn=computers," . $auDN; $dhcp = get_node_data($newhostDN, array("dhcphlpcont")); # print_r($dhcp); echo "<br>"; if ($dhcp['dhcphlpcont'] != "") { $entrydel['dhcphlpcont'] = array(); $entrydel['objectclass'] = "dhcpHost"; # print_r($dhcphlpcont); ldap_mod_del($ds, $newhostDN, $entrydel); } } } } # DHCP Objekte IP Ranges löschen $subnets = get_subnets($childDN, array("dn")); # print_r($subnets); echo "<br>"; if (count($subnets) != 0) { foreach ($subnets as $subnet) { # print_r($subnet['dn']); echo "<br>"; delete_ip_dhcprange($subnet['dn'], $childDN); } } # DHCP Pools auch noch # Freie IP Bereiche zurücknehmen $fipb_array = get_freeipblocks_au($childDN); # print_r($fipb_array); echo "<br>"; # print_r(count($fipb_array)); echo "<br>"; if (count($fipb_array) == 1 && $fipb_array[0] != "") { $entry_ipblock['freeipblock'] = $fipb_array[0]; # print_r($entry_ipblock); echo "<br>"; ldap_mod_add($ds, $auDN, $entry_ipblock); } if (count($fipb_array) > 1) { foreach ($fipb_array as $fipb) { $entry_ipblock['FreeIPBlock'][] = $fipb; # print_r($entry_ipblock); echo "<br>"; ldap_mod_add($ds, $auDN, $entry_ipblock); } } merge_ipranges($auDN); # Verschieben der Childs an neue Stelle $child_childs = get_childau($childDN, array("dn", "ou")); # print_r($child_childs); echo "<br>"; if (count($child_childs) != 0) { foreach ($child_childs as $cc) { $child_childDN = $cc['dn']; $newccDN = "ou=" . $cc['ou'] . "," . $auDN; # print_r($child_childDN); echo " >> "; # print_r($newccDN); echo "<br>"; if (move_subtree($child_childDN, $newccDN)) { adjust_dn_entries($child_childDN, $newccDN); } } } # Löschen des AU Knotens dive_into_tree_del($childDN, ""); $mesg = "<br>Erfolgreich gelöscht mit Integration<br>"; return $mesg; } if ($delmodus == "complete") { # IP Bereiche zurück # DNS Teilbaum Objekte löschen # alles rekursive löschen /*if (dive_into_tree_del($dcDN,"")){ $delentry ['objectclass'] = "domainrelatedobject"; $delentry ['associateddomain'] = $domsuffix; #print_r($delentry); echo "<br>"; $delresult = ldap_mod_del($ds,$childDN,$delentry); if ($delresult){ $mesg = "Domain komplett gelöscht<br>"; }else{$mesg = "Fehler! ldap_mod_del<br>";} }else{$mesg = "Fehler! dive_into_tree_del<br>";} */ $mesg = "Komplettes löschen mometan noch nicht unterstützt.<br>\n\t\t\t\t\tNur eine Ebene mit Integration ...<br>"; return $mesg; } }
function check_hostname($hostname) { global $ds, $suffix, $auDN, $ldapError; $brothercheck = 0; $brotherhosts = get_hosts($auDN, array("hostname"), ""); foreach ($brotherhosts as $item) { if ($item['hostname'] == $hostname) { $brothercheck = 1; break; } } return $brothercheck; }
} } // what site is earth $earth = 1118; // some constants for met formats, this is a list of all models that // implement a CF to model code, with the appropriate output format. $met = array('ED2' => 12, 'SIPNET' => 24, 'CF' => 33, 'DALEC' => 1000000002, 'LINKAGES' => 1000000003, 'MAESPA' => 1000000016, 'LPJGUESS' => 1000000017); $host = isset($_REQUEST['host']) ? $_REQUEST['host'] : ""; $model = isset($_REQUEST['model']) ? $_REQUEST['model'] : ""; $sitegroup = isset($_REQUEST['sitegroup']) ? $_REQUEST['sitegroup'] : ""; // Start XML file, create parent node $dom = new DOMDocument("1.0"); $dom->formatOutput = true; $root = $dom->appendChild($dom->createElement("info")); // get information get_hosts(); get_models(); get_sites(); echo $dom->saveXML(); close_database(); // ---------------------------------------------------------------------- // SITES // ---------------------------------------------------------------------- function get_hosts() { global $pdo, $dom, $root, $hostlist; global $model; $parnode = $root->appendChild($dom->createElement("hosts")); // check for hosts $query = "SELECT machines.* FROM machines"; $subs = array();
<?php include '../standard_header.inc.php'; $syntax = new Syntaxcheck(); $rbscn = "RBS_" . $_POST['rbscn']; $oldrbscn = "RBS_" . $_POST['oldrbscn']; $tftpserverip = $_POST['tftpserverip']; $oldtftpserverip = $_POST['oldtftpserverip']; $rbsoffer = $_POST['rbsoffer']; $oldrbsoffer = $_POST['oldrbsoffer']; $tftpserver = $_POST['tftpserver']; $oldtftpserverdn = $_POST['oldtftpserverdn']; $host_array = get_hosts($auDN, array("dn", "hostname", "ipaddress")); $rbsDN = $_POST['rbsdn']; $nodeDN = "cn=rbs," . $auDN; $mnr = $_POST['mnr']; $sbmnr = $_POST['sbmnr']; $mcnr = $_POST['mcnr']; # sosntige Attribute $attribs = $_POST['attribs']; if (count($attribs) != 0) { foreach (array_keys($attribs) as $key) { $atts[$key] = htmlentities($attribs[$key]); } } #print_r($atts); echo "<br><br>"; $oldattribs = $_POST['oldattribs']; if (count($oldattribs) != 0) { foreach (array_keys($oldattribs) as $key) { $oldatts[$key] = htmlentities($oldattribs[$key]); }
function check_group(&$url) { $hosts = get_hosts(); if ($hosts) { $p_url = parse_url($url); $_parts = explode('.', $p_url['host']); while ($_parts) { $_host = join('.', $_parts); if (isset($hosts[$_host])) { if (defined('XOOPS_URL') && $url !== $hosts[$_host]) { //header('Etag: '. md5($url)); //header('Cache-Control: public, max-age=' . FAVICON_CACHE_TTL ); //header('Expires: ' . gmdate( "D, d M Y H:i:s", UNIX_TIME + FAVICON_CACHE_TTL ) . ' GMT'); header('HTTP/1.1 301 Moved Permanently'); header('Location:' . XOOPS_URL . '/class/hyp_common/favicon.php?url=' . rawurlencode($hosts[$_host])); exit; } $url = $hosts[$_host]; break; } array_shift($_parts); } } }
$template->define_dynamic("Altrbs", "Webseite"); foreach ($rbsoffers as $item) { $rbsdnexp = ldap_explode_dn($item, 1); $rbsoffcn = $rbsdnexp[0]; $rbsoffau = $rbsdnexp[2]; #$auexp = explode(',',$item['auDN']); #$altrbsau = explode('=',$auexp[0]); $template->assign(array("ALTRBSDN" => $item, "ALTRBSCN" => $rbsoffcn, "ALTRBSAU" => " [ Abt.: " . $rbsoffau . " ]")); $template->parse("ALTRBS_LIST", ".Altrbs"); } } ################################################# # Ziel Objekt (nur Rechner und Gruppen, nicht Default) $hostorgroup = $exp[0]; $hgexp = explode('=', $exp[0]); $hosts_array = get_hosts($auDN, array("dn", "hostname", "hlprbservice", "hwaddress"), ""); if (count($hosts_array) != 0) { $template->define_dynamic("Hosts", "Webseite"); foreach ($hosts_array as $item) { # Nur Hosts die in DHCP/TFTP angemeldet und deren MAC eingetragen ist (für PXE-Filename) if ($item['hlprbservice'] != "" && $item['hwaddress'] != "") { $template->assign(array("HDN" => $item['dn'], "HN" => $item['hostname'])); $template->parse("HOSTS_LIST", ".Hosts"); } } } $groups_array = get_groups($auDN, array("dn", "cn", "hlprbservice")); if (count($groups_array) != 0) { $template->define_dynamic("Groups", "Webseite"); foreach ($groups_array as $item) { if ($item['hlprbservice'] != "") {
function add_task($task, $hosts) { /*{{{*/ // check task CronTask::parseRule($task); $matched_hosts = get_hosts($hosts); foreach ((array) $matched_hosts as $host) { color_echo("add task [{$task}] to {$host}\n", 'green'); if (!add_task_to_host($task, $host)) { color_echo("add task to {$host} failed\n", "red"); } } return true; }
* If you have any feedback please consult http://openslx.org/feedback and * send your suggestions, praise, or complaints to feedback@openslx.org * * General information about OpenSLX can be found at http://openslx.org/ * ----------------------------------------------------------------------------- * searchDB.php * - Read data from the LDAP database ... * ----------------------------------------------------------------------------- */ session_start(); require 'ldap3.inc.php'; $ds = uniLdapConnect(USER, PASS); // to be defined accordingly $auDN = "ou=Lehrpool1,ou=Rechenzentrum,ou=UniFreiburg,ou=RIPM,dc=uni-freiburg,dc=de"; $attributes = array("hostname", "domainname", "ipaddress", "hwaddress"); $res = get_hosts($auDN, $attributes, ""); echo "Seite fuer das Suchen in der DB...<br>"; echo "<form action='index.php?section=sendchoice' method='POST'>"; $_SESSION['hosts'] = $res; $template = "%s, %s, %s, %s <input type=\"checkbox\" name=\"choice[%s]\" />"; $template .= "<br/>"; foreach ($res as $key => $entries) { /* echo $entries["hostname"].", ".$entries["domainname"].", ".$entries["ipaddress"].", ".$entries["hwaddress"]; echo "<input type='checkbox' name='choice["; echo%s $key; echo "]' />"; /*echo "<input type='hidden' name='ip[".$entries["hwaddress"]."]' value=\"".$entries["ipaddress"]."\"/>"; echo "<input type='hidden' name='host[".$entries["hwaddress"]."]' value=\"".$entries["hostname"]."\"/>"; echo "<input type='hidden' name='dn[".$entries["hwaddress"]."]' value=\"".$entries["domainname"]."\"/>"; echo "<br>";
$webseite = "hostoverview.dwt"; include 'computers_header.inc.php'; $mnr = 0; $sbmnr = -1; $mcnr = -1; ################################################################################### # Menuleisten erstellen createMainMenu($rollen, $mainnr); createComputersMenu($rollen, $mnr, $auDN, $sbmnr, $mcnr); ################################################################################### #session_unregister( 'entries' ); $sort = "hostname"; $sort = $_GET['sort']; $template->assign(array("DN" => "", "HOSTNAME" => "Noch keine Rechner angelegt", "DOMAINNAME" => "", "HWADDRESS" => "", "IPADDRESS" => "", "DHCPCONT" => "", "FIXADD" => "", "DSC" => "", "GEOLOC" => "", "GEOATT" => "", "HWINV" => "", "INV" => "", "RBSCONT" => "", "CHECK" => "")); $attributes = array("dn", "hostname", "domainname", "hwaddress", "ipaddress", "description", "dhcphlpcont", "dhcpoptfixed-address", "hlprbservice", "dhcpoptnext-server", "inventarnr", "hwinventarnr", "geolocation", "geoattribut"); $host_array = get_hosts($auDN, $attributes, $sort); # Host Array sortieren switch ($sort) { case "ipaddress": $host_array = array_natsort($host_array, "ipaddress", "ipaddress"); break; case "hwaddress": $host_array = array_sort($host_array, "hwaddress", "hwaddress"); break; case "description": $host_array = array_natsort($host_array, "description", "description"); break; case "geolocation": $host_array = array_sort($host_array, "geolocation", "geolocation"); break; case "inventarnr":