function ripeTab($id) { $ripe_db = "http://rest.db.ripe.net/search.xml?source=ripe&query-string="; assertUIntArg('id'); $net = spotEntity('ipv4net', $id); loadIPAddrList($net); $startip = ip4_bin2int($net['ip_bin']); $endip = ip4_bin2int(ip_last($net)); // Get Data from RIPE $ripe_inetnum_str = ip4_format(ip4_int2bin($startip)) . ' - ' . ip4_format(ip4_int2bin($endip)); $ripe_query = $ripe_db . ip4_format(ip4_int2bin($startip)); $ripe_result_str = file_get_contents($ripe_query, false, NULL); $ripe_result = simplexml_load_string($ripe_result_str); // Check inetnum object $ripe_inetnum_check = "/whois-resources/objects/object[@type='inetnum']/attributes/attribute[@name='inetnum'][@value='{$ripe_inetnum_str}']"; $ripe_inetnum = $ripe_result->xpath($ripe_inetnum_check); if (empty($ripe_inetnum)) { echo "<div class=trerror><center><h1>{$net['ip']}/{$net['mask']}</h1><h2>{$net['name']}</h2></center></div>\n"; } else { $ripe_netname_check = "/whois-resources/objects/object[@type='inetnum']/attributes/attribute[@name='netname']"; $ripe_netname = $ripe_result->xpath($ripe_netname_check); $netname = trim($ripe_netname[0]['value']); if (strcmp($netname, $net['name']) != 0) { echo "<div class=trwarning><center><h1>{$net['ip']}/{$net['mask']}</h1><h2>{$net['name']}</h2></center></div><div><center>"; } else { echo "<div class=trok><center><h1>{$net['ip']}/{$net['mask']}</h1><h2>{$net['name']}</h2></center></div><div><center>"; } printOpFormIntro('importRipeData', array('ripe_query' => $ripe_query, 'net_id' => $id, 'net_name' => $netname)); echo "<input type=submit value='Import RIPE records in to comments'></center></div>"; echo "</form>"; } // echo '<em>'.$ripe_query.'</em>'; echo "<table border=0 width='100%'><tr><td class=pcleft>"; $filedir = realpath(dirname(__FILE__)); $ripe_xsl = simplexml_load_file($filedir . '/ripe_html.xsl'); startPortlet("RIPE Information Datatbase<br>{$ripe_inetnum_str}"); $proc = new XSLTProcessor(); $proc->importStyleSheet($ripe_xsl); echo '<div class=commentblock>' . trim($proc->transformToXML($ripe_result)) . '</div>'; finishPortlet(); echo "</td></tr></table>\n"; }
function renderVLANMembership($object_id) { try { $data = getSwitchVLANs($object_id); } catch (RTGatewayError $re) { showWarning('Device configuration unavailable:<br>' . $re->getMessage()); return; } list($vlanlist, $portlist, $maclist) = $data; $vlanpermissions = array(); foreach ($portlist as $port) { if (array_key_exists($port['vlanid'], $vlanpermissions)) { continue; } $vlanpermissions[$port['vlanid']] = array(); foreach (array_keys($vlanlist) as $to) { if (permitted(NULL, NULL, 'setPortVLAN', array(array('tag' => '$fromvlan_' . $port['vlanid']), array('tag' => '$vlan_' . $port['vlanid']))) and permitted(NULL, NULL, 'setPortVLAN', array(array('tag' => '$tovlan_' . $to), array('tag' => '$vlan_' . $to)))) { $vlanpermissions[$port['vlanid']][] = $to; } } } if (isset($_REQUEST['hl_port_id'])) { assertUIntArg('hl_port_id'); $hl_port_id = intval($_REQUEST['hl_port_id']); $object = spotEntity('object', $object_id); amplifyCell($object); foreach ($object['ports'] as $port) { if (mb_strlen($port['name']) && $port['id'] == $hl_port_id) { $hl_port_name = $port['name']; break; } } } echo '<table border=0 width="100%"><tr><td colspan=3>'; startPortlet('Current status'); echo "<table class=widetable cellspacing=3 cellpadding=5 align=center width='100%'><tr>"; printOpFormIntro('setPortVLAN'); $portcount = count($portlist); echo "<input type=hidden name=portcount value=" . $portcount . ">\n"; $portno = 0; $ports_per_row = 12; foreach ($portlist as $port) { // Don't let wide forms break our fancy pages. if ($portno % $ports_per_row == 0) { if ($portno > 0) { echo "</tr>\n"; } echo "<tr><th>" . ($portno + 1) . "-" . ($portno + $ports_per_row > $portcount ? $portcount : $portno + $ports_per_row) . "</th>"; } $td_class = 'port_'; if ($port['status'] == 'notconnect') { $td_class .= 'notconnect'; } elseif ($port['status'] == 'disabled') { $td_class .= 'disabled'; } elseif ($port['status'] != 'connected') { $td_class .= 'unknown'; } elseif (!isset($maclist[$port['portname']])) { $td_class .= 'connected_none'; } else { $maccount = 0; foreach ($maclist[$port['portname']] as $vlanid => $addrs) { $maccount += count($addrs); } if ($maccount == 1) { $td_class .= 'connected_single'; } else { $td_class .= 'connected_multi'; } } if (isset($hl_port_name) and strcasecmp($hl_port_name, $port['portname']) == 0) { $td_class .= (strlen($td_class) ? ' ' : '') . 'border_highlight'; } echo "<td class='{$td_class}'>" . $port['portname'] . '<br>'; echo "<input type=hidden name=portname_{$portno} value=" . $port['portname'] . '>'; if ($port['vlanid'] == 'trunk') { echo "<input type=hidden name=vlanid_{$portno} value='trunk'>"; echo "<select disabled multiple='multiple' size=1><option>TRUNK</option></select>"; } elseif ($port['vlanid'] == 'routed') { echo "<input type=hidden name=vlanid_{$portno} value='routed'>"; echo "<select disabled multiple='multiple' size=1><option>ROUTED</option></select>"; } elseif (!array_key_exists($port['vlanid'], $vlanpermissions) or !count($vlanpermissions[$port['vlanid']])) { echo "<input type=hidden name=vlanid_{$portno} value={$port['vlanid']}>"; echo "<select disabled name=vlanid_{$portno}>"; echo "<option value={$port['vlanid']} selected>{$port['vlanid']}</option>"; echo "</select>"; } else { echo "<select name=vlanid_{$portno}>"; // A port may belong to a VLAN, which is absent from the VLAN table, this is normal. // We must be able to render its SELECT properly at least. $in_table = FALSE; foreach ($vlanpermissions[$port['vlanid']] as $v) { echo "<option value={$v}"; if ($v == $port['vlanid']) { echo ' selected'; $in_table = TRUE; } echo ">{$v}</option>\n"; } if (!$in_table) { echo "<option value={$port['vlanid']} selected>{$port['vlanid']}</option>\n"; } echo "</select>"; } $portno++; echo "</td>"; } echo "</tr><tr><td colspan=" . ($ports_per_row + 1) . "><input type=submit value='Save changes'></form></td></tr></table>"; finishPortlet(); echo '</td></tr><tr><td class=pcleft>'; startPortlet('VLAN table'); echo '<table class=cooltable cellspacing=0 cellpadding=5 align=center width="100%">'; echo "<tr><th>ID</th><th>Description</th></tr>"; $order = 'even'; global $nextorder; foreach ($vlanlist as $id => $descr) { echo "<tr class=row_{$order}><td class=tdright>{$id}</td><td class=tdleft>{$descr}</td></tr>"; $order = $nextorder[$order]; } echo '</table>'; finishPortlet(); echo '</td><td class=pcright>'; startPortlet('Color legend'); echo '<table>'; echo "<tr><th>port state</th><th>color code</th></tr>"; echo "<tr><td>not connected</td><td class=port_notconnect>SAMPLE</td></tr>"; echo "<tr><td>disabled</td><td class=port_disabled>SAMPLE</td></tr>"; echo "<tr><td>unknown</td><td class=port_unknown>SAMPLE</td></tr>"; echo "<tr><td>connected with none MAC addresses active</td><td class=port_connected_none>SAMPLE</td></tr>"; echo "<tr><td>connected with 1 MAC addresses active</td><td class=port_connected_single>SAMPLE</td></tr>"; echo "<tr><td>connected with 1+ MAC addresses active</td><td class=port_connected_multi>SAMPLE</td></tr>"; echo '</table>'; finishPortlet(); echo '</td><td class=pcright>'; if (count($maclist)) { startPortlet('MAC address table'); echo '<table border=0 class=cooltable align=center cellspacing=0 cellpadding=5>'; echo "<tr><th>Port</th><th>VLAN ID</th><th>MAC address</th></tr>\n"; $order = 'even'; foreach ($maclist as $portname => $portdata) { foreach ($portdata as $vlanid => $addrgroup) { foreach ($addrgroup as $addr) { echo "<tr class=row_{$order}><td class=tdleft>{$portname}</td><td class=tdleft>{$vlanid}</td>"; echo "<td class=tdleft>{$addr}</td></tr>\n"; $order = $nextorder[$order]; } } } echo '</table>'; finishPortlet(); } // End of main table. echo '</td></tr></table>'; }
function renderLVSConfig($object_id) { printOpFormIntro('submitSLBConfig'); echo "<center><input type=submit value='Submit for activation'></center>"; echo "</form>"; echo "<pre>" . buildLVSConfig($object_id) . "</pre>"; }
function renderNewVSGForm() { startPortlet('Add new VS group'); printOpFormIntro('add'); echo '<table border=0 cellpadding=5 cellspacing=0 align=center>'; echo '<tr valign=bottom><th>Name:</th><td class="tdleft">'; echo '<input type=text name=name></td></tr>'; echo '<tr><th>Tags:</th><td class="tdleft">'; printTagsPicker(); echo '</td></tr>'; echo '</table>'; printImageHREF('CREATE', 'create virtual service', TRUE); echo '</form>'; finishPortlet(); }
/** * * Fing tab handler * */ function FingTab($id) { $can_import = permitted(NULL, NULL, 'importFingData'); // // allocation settings // // address allocation code, IPv4 networks view $aac_left = array('regular' => '', 'virtual' => '<span class="aac-left" title="Loopback">L:</span>', 'shared' => '<span class="aac-left" title="Shared">S:</span>', 'router' => '<span class="aac-left" title="Router">R:</span>', 'point2point' => '<span class="aac-left" title="Point-to-point">P:</span>'); // // header // global $pageno, $tabno; $maxperpage = getConfigVar('IPV4_ADDRS_PER_PAGE'); $range = spotEntity('ipv4net', $id); loadIPAddrList($range); echo "<center><h1>{$range['ip']}/{$range['mask']}</h1><h2>{$range['name']}</h2></center>\n"; // // execute fing // try { $known_ips = get_fing_scan($range['ip'], $range['mask']); $fing_cfg = get_fing_settings($range['ip'], $range['mask']); $fing_gw = $fing_cfg["gateway"]; } catch (FingException $e) { render_fing_error("Could not get network scan via fing:", $e->getMessage()); return FALSE; } echo "<table class=objview border=0 width='100%'><tr><td class=pcleft>"; startPortlet('overlook fing (via: ' . $fing_gw . ')'); // // pagination // if (isset($_REQUEST['pg'])) { $page = $_REQUEST['pg']; } else { $page = 0; } $startip = ip4_bin2int($range['ip_bin']); $endip = ip4_bin2int(ip_last($range)); $numpages = 0; if ($endip - $startip > $maxperpage) { $numpages = ($endip - $startip) / $maxperpage; $startip = $startip + $page * $maxperpage; $endip = $startip + $maxperpage - 1; } echo "<center>"; if ($numpages) { echo '<h3>' . ip4_format(ip4_int2bin($startip)) . ' ~ ' . ip4_format(ip4_int2bin($endip)) . '</h3>'; } for ($i = 0; $i < $numpages; $i++) { if ($i == $page) { echo "<b>{$i}</b> "; } else { echo "<a href='" . makeHref(array('page' => $pageno, 'tab' => $tabno, 'id' => $id, 'pg' => $i)) . "'>{$i}</a> "; } } echo "</center>"; if ($can_import) { printOpFormIntro('importFingData', array('addrcount' => $endip - $startip + 1)); $box_counter = 1; } echo "<table class='widetable' border=0 cellspacing=0 cellpadding=5 align='center'>\n"; echo "<tr><th class='tdleft'>address</th><th class='tdleft'>state</th><th class='tdleft'>current name</th><th class='tdleft'>DNS name</th><th class='tdleft'>MAC</th><th class='tdleft'>Allocation</th>"; if ($can_import) { echo '<th>import</th>'; } echo "</tr>\n"; // // Loop through all IPs // $cnt_match = $cnt_missing = $cnt_mismatch = $cnt_total = 0; for ($ip = $startip; $ip <= $endip; $ip++) { $cnt_total++; $print_cbox = FALSE; $ip_bin = ip4_int2bin($ip); $addr = isset($range['addrlist'][$ip_bin]) ? $range['addrlist'][$ip_bin] : array('name' => '', 'reserved' => 'no'); $straddr = ip4_format($ip_bin); list($fing_hostname, $fing_state, $fing_mac_vendor) = get_fing_info($straddr, $known_ips); $ip_is_up = strtoupper($fing_state) == "UP" ? TRUE : FALSE; if ($can_import) { echo "<input type=hidden name=addr_{$cnt_total} value={$straddr}>\n"; echo "<input type=hidden name=descr_{$cnt_total} value={$fing_hostname}>\n"; echo "<input type=hidden name=rsvd_{$cnt_total} value={$addr['reserved']}>\n"; } $skip_dns_check = FALSE; echo "<tr"; // Ignore network and broadcast addresses if ($ip == $startip && $addr['name'] == 'network' || $ip == $endip && $addr['name'] == 'broadcast') { echo " class='trbusy'"; $skip_dns_check = TRUE; } elseif (!$ip_is_up) { echo " class='trnull'"; } // set line color depending if we have the name already in the DB if (!$skip_dns_check) { if ($addr['name'] == $fing_hostname) { if (strlen($fing_hostname)) { echo ' class=trok'; $cnt_match++; } } elseif (!strlen($addr['name']) or !strlen($fing_hostname)) { echo ' class=trwarning'; $print_cbox = TRUE; $cnt_missing++; } else { echo ' class=trerror'; $print_cbox = TRUE; $cnt_mismatch++; } } //IP echo "><td class='tdleft"; if (isset($range['addrlist'][$ip_bin]['class']) and strlen($range['addrlist'][$ip_bin]['class'])) { echo ' ' . $range['addrlist'][$ip_bin]['class']; } echo "'><a href='" . makeHref(array('page' => 'ipaddress', 'ip' => $straddr)) . "'>{$straddr}</a></td>"; //other columns if ($skip_dns_check) { echo "<td class='tdleft'> </td>"; } else { if (!$ip_is_up) { echo "<td class='tdleft'>" . $fing_state . "</td>"; } else { echo "<td class='tdleft'><div class='strong'>" . $fing_state . "</div></td>"; } } echo "<td class=tdleft>{$addr['name']}</td>"; echo "<td class='tdleft'>" . $fing_hostname . "</td>"; echo "<td class='tdleft'>" . $fing_mac_vendor . "</td>"; //allocation echo "<td>"; $delim = ''; if ($addr['reserved'] == 'yes') { echo "<strong>RESERVED</strong> "; $delim = '; '; } foreach ($addr['allocs'] as $ref) { echo $delim . $aac_left[$ref['type']]; echo makeIPAllocLink($ip_bin, $ref, TRUE); $delim = '; '; } if ($delim != '') { $delim = '<br>'; } foreach ($addr['vslist'] as $vs_id) { $vs = spotEntity('ipv4vs', $vs_id); echo $delim . mkA("{$vs['name']}:{$vs['vport']}/{$vs['proto']}", 'ipv4vs', $vs['id']) . '→'; $delim = '<br>'; } foreach ($addr['vsglist'] as $vs_id) { $vs = spotEntity('ipvs', $vs_id); echo $delim . mkA($vs['name'], 'ipvs', $vs['id']) . '→'; $delim = '<br>'; } foreach ($addr['rsplist'] as $rsp_id) { $rsp = spotEntity('ipv4rspool', $rsp_id); echo "{$delim}→" . mkA($rsp['name'], 'ipv4rspool', $rsp['id']); $delim = '<br>'; } echo "</td>"; // import column if ($can_import) { echo '<td>'; if ($print_cbox) { echo "<input type=checkbox name=import_{$cnt_total} id=atom_1_" . $box_counter++ . "_1>"; } else { echo ' '; } echo '</td>'; } echo "</tr>"; } if ($can_import && $box_counter > 1) { echo '<tr><td colspan=4 align=center><input type=submit value="Import selected records"></td><td colspan=2 align=right>'; addJS('js/racktables.js'); echo --$box_counter ? "<a href='javascript:;' onclick=\"toggleColumnOfAtoms(1, 1, {$box_counter})\">(toggle selection)</a>" : ' '; echo '</td></tr>'; } echo "</table>"; if ($can_import) { echo '</form>'; } finishPortlet(); echo "</td><td class=pcright>"; // // PING Statistics // startPortlet('ping stats'); $cnt_ping_up = get_fing_up_count($known_ips); echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>"; echo "<tr class=trok><th class=tdright>Replied to Ping</th><td class=tdleft>{$cnt_ping_up}</td></tr>\n"; echo "<tr class=trwarning><th class=tdright>No Response</th><td class=tdleft>" . ($cnt_total - $cnt_ping_up) . "</td></tr>\n"; echo "</table>\n"; finishPortlet(); // // DNS Statistics // startPortlet('dns stats'); echo "<table border=0 width='100%' cellspacing=0 cellpadding=2>"; echo "<tr class=trok><th class=tdright>Exact matches:</th><td class=tdleft>{$cnt_match}</td></tr>\n"; echo "<tr class=trwarning><th class=tdright>Missing from DB/DNS:</th><td class=tdleft>{$cnt_missing}</td></tr>\n"; if ($cnt_mismatch) { echo "<tr class=trerror><th class=tdright>Mismatches:</th><td class=tdleft>{$cnt_mismatch}</td></tr>\n"; } echo "</table>\n"; finishPortlet(); }
function printNewitemTR($column) { printOpFormIntro('add'); echo '<tr>'; echo '<td> </td>'; echo '<td class=tdleft>' . getImageHREF('create', 'create new', TRUE, 200) . '</td>'; echo "<td><input type=text size={$column['width']} name={$column['value']} tabindex=100></td>"; echo '<td class=tdleft>' . getImageHREF('create', 'create new', TRUE, 200) . '</td>'; echo '</tr></form>'; }
function renderEditUCSForm() { startPortlet('UCS Actions'); printOpFormIntro('autoPopulateUCS'); echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>'; echo "<tr><th class=tdright><label for=ucs_login>Login:</label></th>"; echo "<td class=tdleft colspan=2><input type=text name=ucs_login id=ucs_login></td></tr>\n"; echo "<tr><th class=tdright><label for=ucs_password>Password:</label></th>"; echo "<td class=tdleft colspan=2><input type=password name=ucs_password id=ucs_password></td></tr>\n"; echo "<tr><th colspan=3><input type=checkbox name=use_terminal_settings id=use_terminal_settings>"; echo "<label for=use_terminal_settings>Use Credentials from terminal_settings()</label></th></tr>\n"; echo "<tr><th class=tdright>Actions:</th><td class=tdleft>"; printImageHREF('DQUEUE sync_ready', 'Auto-populate UCS', TRUE); echo '</td><td class=tdright>'; echo "<a href='" . makeHrefProcess(array('op' => 'cleanupUCS', 'object_id' => getBypassValue())) . "' onclick=\"javascript:return confirm('Are you sure you want to cleanup UCS Domain?')\">" . getImageHREF('CLEAR', 'Clean-up UCS domain') . "</a>"; echo "</td></tr></table></form>\n"; finishPortlet(); }
function renderNetworkEditAttrs() { global $pageno, $netobject_type_id; $network = spotEntity($pageno === 'ipv4net' ? 'ipv4net' : 'ipv6net', getBypassValue()); $values = getAttrValuesForNetwork($network); echo '<p>'; startPortlet("Attributes"); printOpFormIntro('updateAttrs'); // optional attributes echo '<table border=0 cellspacing=0 cellpadding=3 align=center>'; $suggest_records = array(); if (count($values) > 0) { $i = 0; foreach ($values as $record) { if (!permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $record['id']), array('tag' => '$any_op')))) { continue; } echo "<input type=hidden name={$i}_attr_id value={$record['id']}>"; echo '<tr><td>'; if (strlen($record['value'])) { echo "<a href='" . makeHrefProcess(array('op' => 'clearSticker', 'id' => $network['id'], 'attr_id' => $record['id'])) . "'>"; printImageHREF('clear', 'Clear value'); echo '</a>'; } else { echo ' '; } echo '</td>'; echo "<th class=sticker>{$record['name']}:</th><td class=tdleft>"; switch ($record['type']) { case 'uint': case 'float': case 'string': echo "<input type=text name={$i}_value value='{$record['value']}'>"; break; case 'dict': $suggest_records = array(); $chapter = readChapter($record['chapter_id'], 'o'); foreach ($chapter as $id => $value) { $suggest_records[$id] = array("id" => $id, "tag" => $value); } printSuggestedInput($i . "_value", $suggest_records, array("id" => $record['key']), "macros"); enableTagsPicker(); break; case 'date': $date_value = $record['value'] ? date(getConfigVar('DATETIME_FORMAT'), $record['value']) : ''; echo "<input type=text name={$i}_value value='{$date_value}'>"; break; } $i++; echo '<input type=hidden name=num_attrs value=' . $i . ">\n"; } } echo '</table>'; printImageHREF('SAVE', 'Save changes', TRUE); echo '</form>'; finishPortlet(); }
function renderPatchCableHeapAmount() { echo '<table class=widetable border=0 cellpadding=5 cellspacing=0 align=center>'; echo '<tr><th colspan=3>Amount</th><th>End 1</th><th>Cable type</th><th>End 2</th><th>Length</th><th>Description</th><th> </th></tr>'; foreach (getPatchCableHeapSummary() as $heap) { printOpFormIntro('set', array('id' => $heap['id'])); echo '<tr>'; echo '<td>'; if ($heap['amount'] > 0) { echo getOpLink(array('op' => 'dec', 'id' => $heap['id']), '', 'delete', 'consume'); } else { echo getImageHREF('nodelete'); } echo '</td>'; echo "<td><input type=text size=7 name=amount value='{$heap['amount']}'></td>"; echo '<td>' . getOpLink(array('op' => 'inc', 'id' => $heap['id']), '', 'add', 'replenish') . '</td>'; echo '<td>' . stringForTD($heap['end1_connector'], 32) . '</td>'; echo '<td>' . stringForTD($heap['pctype'], 255) . '</td>'; echo '<td>' . stringForTD($heap['end2_connector'], 32) . '</td>'; echo "<td class=tdright>{$heap['length']}</td>"; echo '<td>' . stringForTD($heap['description'], 255) . '</td>'; echo '<td>' . getImageHREF('save', 'Save changes', TRUE) . '</td>'; echo '</tr></form>'; } echo '</table>'; }
function localfunc_ObjectCopier($object_id) { $object = spotEntity('object', $object_id); amplifyCell($object); global $virtual_obj_types, $tagtree, $taglist, $target_given_tags; $typelist = readChapter(CHAP_OBJTYPE, 'o'); $typelist[0] = 'select type...'; $typelist = cookOptgroups($typelist); $max = getConfigVar('MASSCOUNT'); $tabindex = 100; echo "\n"; echo "\n<!-- printOpFormIntro ('copyLotOfObjects') -->\n"; printOpFormIntro('copyLotOfObjects'); echo "\n"; startPortlet('Make many copies of this object'); echo "\n" . sprintf('<table border=%s align=center>', TABLE_BORDER); echo "\n" . '<tr><th align=left>name or "name","label","asset_no" (no csv escaping)<br><br>'; echo 'Example:<br> "server.example.com","server.example.com","12345"<br>www.example.com<br>testmachine<br>'; echo '</th><th>Copy Tags</th></tr>'; //echo "<tr><td><input type=submit name=got_very_fast_data value='Go!'></td><td></td></tr>\n"; echo "\n" . "<tr><td valign=top ><textarea name=namelist cols=60 rows=35>\n</textarea></td>"; echo "<td valign=top>"; printf("<input type=hidden name=global_type_id value='%s'>\n", $object['objtype_id']); //renderCopyEntityTagsPortlet ('Tag tree', $tagtree, $target_given_tags, $etype_by_pageno[$pageno]); renderCopyEntityTags($object); echo "</td></tr>"; echo "<tr><td colspan=2><input type=submit name=got_very_fast_data value='Go!'></td></tr></table>\n"; echo "</form>\n"; finishPortlet(); }
function renderNodePingChecks($object_id) { $accounts = getNodePingAccounts(); $account_options = array(); foreach ($accounts as $account) { $account_options[$account['id']] = $account['name']; } startPortlet('Add new check'); echo "<table cellspacing=0 cellpadding=5 align='center'>\n"; echo "<tr><th> </th><th>Account</th><th>Check ID</th><th></th><th> </th></tr>\n"; printOpFormIntro('add'); echo '<tr><td>'; printImageHREF('add', 'add check', TRUE); echo '</td><td>' . getSelect($account_options, array('name' => 'account_id')); echo '</td><td><input type=text size=25 name=np_check_id tabindex=101></td><td>'; printImageHREF('add', 'add check', TRUE); echo "</td></tr></form></table>\n"; finishPortlet(); $checks = getUnlinkedNodePingChecks($object_id); if (count($checks) > 0) { $check_options = array(); foreach ($checks as $check) { $check_options[$check['id']] = sprintf("%s - %s", $check['label'], $check['type']); } startPortlet('Link existing check (' . count($checks) . ')'); echo "<table cellspacing=0 cellpadding=5 align='center'>\n"; printOpFormIntro('link'); echo '<tr><td>' . getSelect($check_options, array('name' => 'check_id')); echo '</td><td class=tdleft>'; printImageHREF('ATTACH', 'Link check', TRUE); echo "</td></tr></form></table>\n"; finishPortlet(); } addJs(<<<END function toggleVisibility(tbodyId) { \t\$("#" + tbodyId).toggle(); } END , TRUE); $checks = getNodePingChecks($object_id); startPortlet('NodePing checks (' . count($checks) . ')'); if (count($checks)) { echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n"; echo "<tr><th> </th><th>Type</th><th>Label</th><th>Interval</th><th>Reason</th><th>Result</th><th>Unlink</th><th> </th></tr>\n"; $token = ''; foreach ($checks as $check) { printOpFormIntro('upd', array('check_id' => $check['check_id'])); echo '<tr><td><a href="' . makeHrefProcess(array('op' => 'del', 'check_id' => $check['check_id'])) . '">'; echo getImageHREF('delete', 'Unlink and delete this check') . '</a></td>'; echo "<td><a href=\"#\" onclick=\"toggleVisibility('{$check['check_id']}');\">{$check['type']}</a></td>"; echo "<td>{$check['label']}</td>"; echo "<td>{$check['check_interval']}</td>"; // re-use a nodeping object if it already exists and is using the same token as this check if ($check['token'] != $token) { $nodeping = new NodePingClient(array('token' => $check['token'])); } $token = $check['token']; $np_result_raw = $nodeping->result->get(array('id' => $check['np_check_id'], 'limit' => 5, 'clean' => true)); if (isset($np_result_raw['error'])) { echo "<td colspan=5>Error: {$check_status_raw['error']}</td>"; } else { $np_result = $np_result_raw[0]; if ($np_result['su']) { $reason = ''; $result_str = 'PASS'; $result_class = 'msg_success'; } else { $reason = $np_result['sc']; $result_str = 'FAIL'; $result_class = 'msg_error'; } echo "<td>{$reason}</td>"; echo "<td><span class='{$result_class}'>{$result_str}</span></td>"; } echo '<td class=center><a href="' . makeHrefProcess(array('op' => 'unlink', 'link_id' => $check['link_id'])) . '">'; echo getImageHREF('cut', 'Unlink this check') . '</a></td>'; echo '<td class=tdleft>'; printImageHREF('save', 'Save changes', TRUE); echo "</td></tr>\n"; echo "<tbody id='{$check['check_id']}' style='display:none;'><tr><td colspan=8>"; echo '<table cellspacing=0 cellpadding=5 align=left>'; // override the td styling so it doesn't have a border echo '<tr><th>Account</th><td align=left style="border-top: 0px;">' . getSelect($account_options, array('name' => 'account_id'), $check['account_id']) . '</td></tr>'; echo '<tr><th>Check ID</th><td align=left style="border-top: 0px;"><input type=text size=25 name=np_check_id value="' . $check['np_check_id'] . '"></td></tr>'; echo "<tr><th>Target</th><td align=left style=\"border-top:0px; word-wrap:break-word; max-width:250px;\">{$check['target']}</td></tr>"; echo '</table></form>'; echo '<table cellspacing=0 cellpadding=5 align=right>'; echo '<tr><th colspan=5>Last 5 Results</th></tr>'; echo '<tr><th>Time</th><th>Loc</th><th>Run Time</th><th>Response</th><th>Result</th></tr>'; foreach ($np_result_raw as $np_row) { // time is reported in miliseconds, so trim off the last 3 digits printf('<tr><td>%s</td>', date('H:i:s A', substr($np_row['s'], 0, -3))); printf('<td>%s</td>', strtoupper($np_row['l'][$np_row['s']])); if ($np_row['su']) { $result_str = 'PASS'; $result_class = 'msg_success'; } else { $result_str = 'FAIL'; $result_class = 'msg_error'; } echo "<td>{$np_row['rt']}</td>"; echo "<td>{$np_row['sc']}</td>"; echo "<td><span class='{$result_class}'>{$result_str}</span></td></tr>"; } echo '</table>'; echo "</td></tr></tbody>\n"; } echo "</table>\n"; } finishPortlet(); }
function localfunc_PortGenerator() { global $errorText, $lookFor, $portList, $genText, $valueConfiguration, $searchIt; assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); startPortlet("Port generator"); print "<center><br>"; if (!localverify_PortGenerator($object)) { // // Autoport configuration did not work. Show this and show the error // print "{$lookFor} : Error\n"; if (isset($errorText)) { print $errorText; } } else { // // Show the list of ports that will be generated and provide a link to actually do so // print "<a href='" . makeHrefProcess(array('op' => 'addports', 'page' => 'object', 'object_id' => $object['id'], 'tab' => 'ports')) . "'>Generate the ports for <b>{$object['name']}</b> as listed below NOW</a><br>\n"; print $genText . "<p>"; print "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>"; print "<tr><th>Port name </th><th>Port label </th><th>Port type</th></tr>\n"; foreach ($portList as $aPort) { print "<tr><td>{$aPort['name']}</td><td>{$aPort['label']}</td><td>{$aPort['port_name']}</td></tr>\n"; } print "</table>"; } print "<br></center>"; finishPortlet(); // // Check whether the user is allowed to do an update of the port configurator // // if you do not want this, make sure you add a // deny {$op_updateportgenerator} // for the apprioriate groups (or any allow first and deny for the rest // if (permitted('object', 'portgenerator', null, array(array('tag' => '$op_updateportgenerator')))) { startPortlet("Update autoport configuration"); // // Description of the config rules // print "<center>"; print $genText . "<p>\n"; print "<b>USAGE</b><br><br>"; print "<list1>;<list2>;.... where <listx> is<br>"; print "<start port #>|<port count, use %n for number of ports>|"; print "<port name, use %u for number>|[<port innerinterface id>-]<port type id>[|<port label, use %u for number>]<br><br>"; print "<b>EXAMPLE (for Force10 S4810)</b><br><br>0|48|%u|9-1084|TenGigabitEthernet0/%u;48|4|%u|10-1588|FortyGigE0/48;52|4|%u|10-1588|FortyGigE0/52;56|4|%u|10-1588|FortyGigE0/56;60|4|%u|10-1588|FortyGigE0/60;1|1|RS-232|29|Serial port;1|1|Ethernet|24|ManagementEthernet0/%u;1|2|AC%u|16<br><br>"; print "<b>EXPLANATION (for AC-in ports)</b><br><br> <b>1</b> = starting number,\n <b>2</b> = number of generated ports, \n <b>AC%u</b> = will begin with <b>starting number</b> and create up to the <b>number of generated ports</b>, \n <b>16</b> = the value displayed on the chart below <b>in bold</b> (Notice: Default innerinterface ID is 1 /hardwired/, so the realy value is <b>1-16</b>)<br><br>"; //explains example print "<b>PLEASE NOTE</b><br><br> If you do not add the port that is selected <b>(dictionary value)</b> to the default list in the <b>Ports</b> Tab, \n you will get a <b>foriegn key violation</b> error. \n You must go to the <b>Configuration</b> area on the main page, go to <b>Enable port types</b>\n and hit the <b>Edit</b> tab to place the selected port in either <b>GBIC</b>, <b>hardwired</b>, or any other configuration \n on the page so that the error is not recieved.<br><br><br>"; //Very important to have a sucessful implementation of port generator // // The form that can update the configuration // On top of the table of ports avialabe instead of beneath it // printOpFormIntro('updateportgenerator', array('yId' => $searchIt)); print "<b>Autoport Configuration:</b><br><br><input type='text' style='width:100%; font-size: 16px' name='yConfig' value='"; if ($valueConfiguration) { print $valueConfiguration[0]; } print "'><br><br>\n"; print "<input type='submit' name='autoportconfig' value='"; if ($valueConfiguration) { print "Update"; } else { print "Create"; } print "'>\n"; print "</form>\n"; print "</center><br>"; print "<table border='2' rules=all>\n<tr class=row_odd>"; $isfirst = true; $i = 0; // // List all available port types with their dictionary key // $q = "SELECT IF(iif_id,CONCAT(i.id,'-',o.id),o.id) as ID , IF(iif_id,CONCAT(i.iif_name,' => ',o.oif_name),o.oif_name) as name FROM PortOuterInterface o left join PortInterfaceCompat c on o.id = c.oif_id left join PortInnerInterface i on c.iif_id = i.id order by i.id,o.id"; $result = usePreparedSelectBlade($q); //Changed for new configeration in versions after 0.17.x if ($result == NULL) { print_r($dbxlink->errorInfo()); die; } while ($row4 = $result->fetch(PDO::FETCH_NUM)) { if (!$isfirst && $i % 10 == 0) { print "</td></tr>\n<tr class=" . ($i % 4 == 0 ? "row_odd" : "row_even") . ">"; } else { $isfirst = false; } print "<td><b>{$row4[0]}</b><br>"; //seperated values to make them easier to read print "{$row4[1]}\n</td>"; $i++; } print "</td>\n"; print "</tr></table>\n"; finishPortlet(); } }
function printNewItemTR() { printOpFormIntro('add'); echo '<tr>'; echo '<td>' . getImageHREF('create', 'add a new server', TRUE) . '</td>'; echo '<td><input type=text size=48 name=base_url></td>'; echo '<td> </td>'; echo '<td>' . getImageHREF('create', 'add a new server', TRUE) . '</td>'; echo '</tr></form>'; }