function getOpLink($params, $title, $img_name = '', $comment = '', $class = '') { if (isset($params)) { $ret = '<a href="' . makeHrefProcess($params) . '"'; } else { $ret = '<a href="#" onclick="return false;"'; $class .= ' noclick'; } if (!empty($comment)) { $ret .= ' title="' . htmlspecialchars($comment, ENT_QUOTES) . '"'; } $class = trim($class); if (!empty($class)) { $ret .= ' class="' . htmlspecialchars($class, ENT_QUOTES) . '"'; } $ret .= '>'; if (!empty($img_name)) { $ret .= getImageHREF($img_name, $comment); if (!empty($title)) { $ret .= ' '; } } if (FALSE !== strpos($class, 'need-confirmation')) { addJS('js/racktables.js'); } $ret .= $title . '</a>'; return $ret; }
function getPopupLink($helper, $params, $window_name = '', $img_name = '', $title = '', $comment = '', $class = '') { $ret = ''; $popup_args = 'height=700, width=700, location=no, menubar=no, resizable=yes, scrollbars=yes, status=no, titlebar=no, toolbar=no'; $ret .= '<a href="#"'; $class = trim($class); if (!empty($class)) { $ret .= ' class="' . htmlspecialchars($class, ENT_QUOTES) . '"'; } if (!empty($comment)) { $ret .= 'title="' . htmlspecialchars($comment, ENT_QUOTES) . '"'; } $href = makeHref(array('module' => 'popup', 'helper' => $helper) + makePageParams($params)); $ret .= " onclick=\"window.open('{$href}', '{$window_name}', '{$popup_args}'); return false\">"; if (!empty($img_name)) { $ret .= getImageHREF($img_name, $comment); if (!empty($title)) { $ret .= ' '; } } $ret .= $title; $ret .= '</a>'; return $ret; }
public function dispatch() { header('Content-Type: text/html; charset=UTF-8'); echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' . "\n"; echo '<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">' . "\n"; echo "<head><title>RackTables: access denied</title>\n"; printPageHeaders(); echo "</head><body>"; global $pageno, $tabno, $user_given_tags, $target_given_tags, $auto_tags, $expl_tags, $impl_tags; echo "<table border=1 cellspacing=0 cellpadding=3 width='50%' align=center>\n"; echo '<tr><th colspan=2><h3>' . getImageHREF('DENIED') . ' access denied '; echo getImageHREF('DENIED') . '</h3></th></tr>'; echo "<tr><th width='50%' class=tagchain>User given tags:</th><td class=tagchain>"; echo serializeTags($user_given_tags) . " </td></tr>\n"; echo "<tr><th width='50%' class=tagchain>Target given tags:</th><td class=tagchain>"; echo serializeTags($target_given_tags) . " </td></tr>\n"; echo "<tr><th width='50%' class=tagchain>Effective explicit tags:</th><td class=tagchain>"; echo serializeTags($expl_tags) . " </td></tr>\n"; echo "<tr><th width='50%' class=tagchain>Effective implicit tags:</th><td class=tagchain>"; echo serializeTags($impl_tags) . " </td></tr>\n"; echo "<tr><th width='50%' class=tagchain>Automatic tags:</th><td class=tagchain>"; echo serializeTags($auto_tags) . " </td></tr>\n"; echo "<tr><th width='50%' class=tdright>Requested page:</th><td class=tdleft>{$pageno}</td></tr>\n"; echo "<tr><th width='50%' class=tdright>Requested tab:</th><td class=tdleft>{$tabno}</td></tr>\n"; echo "<tr><td colspan=2 align=center>Click <a href='index.php?logout'>here</a> to logout.</td></tr>\n"; echo "</table>\n"; echo "</body></html>"; }
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 renderSLBTriplets2($cell, $editable = FALSE, $hl_ip = NULL) { list($realm1, $realm2) = array_values(array_diff(array('object', 'ipvs', 'ipv4rspool'), array($cell['realm']))); if ($editable && getConfigVar('ADDNEW_AT_TOP') == 'yes') { callHook('renderNewTripletForm', $realm1, $realm2); } $fields = array('ipvs' => 'vs_id', 'object' => 'object_id', 'ipv4rspool' => 'rspool_id'); $headers = array('ipvs' => 'VS', 'object' => 'LB', 'ipv4rspool' => 'RS pool'); $triplets = groupTriplets(getTriplets($cell)); // sort $headers by number of grouped cells $new_headers = array(); $grouped_by = array('ipvs' => 0, 'object' => 0, 'ipv4rspool' => 0); foreach ($triplets as $slb) { if (isset($slb['span'])) { foreach (array_keys($slb['span']) as $realm) { $grouped_by[$realm]++; } } } arsort($grouped_by, SORT_NUMERIC); foreach (array_keys($grouped_by) as $realm) { $new_headers[$realm] = $headers[$realm]; } $headers = $new_headers; // render table header if (count($triplets)) { startPortlet('VS group instances (' . count($triplets) . ')'); echo "<table cellspacing=0 cellpadding=5 align=center class=widetable><tr><th></th>"; foreach ($headers as $realm => $header) { if ($realm != $cell['realm']) { echo "<th>{$header}</th>"; } } echo '<th>Ports</th>'; echo '<th>VIPs</th>'; echo "</tr>"; } addJS('js/slb_editor.js'); addJS('js/jquery.thumbhover.js'); $class = 'slb-checks'; if ($editable) { $class .= ' editable'; } // render table rows global $nextorder; $order = 'odd'; $span = array(); foreach ($triplets as $slb) { $vs_cell = spotEntity('ipvs', $slb['vs_id']); amplifyCell($vs_cell); echo makeHtmlTag('tr', array('valign' => 'top', 'class' => "row_{$order} triplet-row", 'data-object_id' => $slb['object_id'], 'data-vs_id' => $slb['vs_id'], 'data-rspool_id' => $slb['rspool_id'])); echo '<td><a href="#" onclick="' . "slb_config_preview(event, {$slb['object_id']}, {$slb['vs_id']}, {$slb['rspool_id']}); return false" . '">' . getImageHREF('Zoom', 'config preview') . '</a></td>'; foreach (array_keys($headers) as $realm) { if ($realm == $cell['realm']) { continue; } if (isset($span[$realm])) { if (--$span[$realm] <= 0) { unset($span[$realm]); } } else { $span_html = ''; if (isset($slb['span'][$realm])) { $span[$realm] = $slb['span'][$realm] - 1; $span_html = sprintf("rowspan=%d", $slb['span'][$realm]); } echo "<td {$span_html} class=tdleft>"; $slb_cell = spotEntity($realm, $slb[$fields[$realm]]); renderSLBEntityCell($slb_cell); echo "</td>"; } } // render ports echo "<td class=tdleft><ul class='{$class}'>"; foreach ($vs_cell['ports'] as $port) { echo '<li class="' . (($row = isPortEnabled($port, $slb['ports'])) ? 'enabled' : 'disabled') . '">'; echo formatVSPort($port) . getPopupSLBConfig($row); if ($editable) { renderPopupTripletForm($slb, $port, NULL, $row); } echo '</li>'; } echo '</ul></td>'; // render VIPs echo "<td class=tdleft><ul class='{$class}'>"; foreach ($vs_cell['vips'] as $vip) { $row = isVIPEnabled($vip, $slb['vips']); $li_class = $row ? 'enabled' : 'disabled'; if ($vip['vip'] === $hl_ip && $li_class == 'enabled') { $li_class .= ' highlight'; } echo "<li class='{$li_class}'>"; echo formatVSIP($vip); if (is_array($row) && !empty($row['prio'])) { $prio_class = 'slb-prio slb-prio-' . preg_replace('/\\s.*/', '', $row['prio']); echo '<span class="' . htmlspecialchars($prio_class, ENT_QUOTES) . '">' . htmlspecialchars($row['prio']) . '</span>'; } echo getPopupSLBConfig($row); if ($editable) { renderPopupTripletForm($slb, NULL, $vip, $row); } echo '</li>'; } echo '<ul></td>'; if ($editable) { echo '<td valign=middle>'; printOpFormIntro('del', array('object_id' => $slb['object_id'], 'vs_id' => $slb['vs_id'], 'rspool_id' => $slb['rspool_id'])); printImageHREF('DELETE', 'Remove triplet', TRUE); echo '</form></td>'; } echo "</tr>\n"; $order = $nextorder[$order]; } if (count($triplets)) { echo "</table>\n"; finishPortlet(); } if ($editable && getConfigVar('ADDNEW_AT_TOP') != 'yes') { callHook('renderNewTripletForm', $realm1, $realm2); } }
function renderRack($rack_id, $hl_obj_id = 0) { $rackData = spotEntity('rack', $rack_id); amplifyCell($rackData); markAllSpans($rackData); if ($hl_obj_id > 0) { highlightObject($rackData, $hl_obj_id); } $prev_id = getPrevIDforRack($rackData['row_id'], $rack_id); $next_id = getNextIDforRack($rackData['row_id'], $rack_id); echo "<center><table border=0><tr valign=middle>"; echo '<td><h2>' . mkA($rackData['row_name'], 'row', $rackData['row_id']) . ' :</h2></td>'; if ($prev_id != NULL) { echo '<td>' . mkA(getImageHREF('prev', 'previous rack'), 'rack', $prev_id) . '</td>'; } echo '<td><h2>' . mkA($rackData['name'], 'rack', $rackData['id']) . '</h2></td>'; if ($next_id != NULL) { echo '<td>' . mkA(getImageHREF('next', 'next rack'), 'rack', $next_id) . '</td>'; } echo "</h2></td></tr></table>\n"; $result = usePreparedSelectBlade("SELECT * FROM racktemperature WHERE rackid = ?", array($rack_id)); $row = $result->fetch(PDO::FETCH_ASSOC); if (isset($row['top'])) { echo "<table align=left border=1>\n"; echo "<tr><th>Sensor</th><th>Temperature</th></tr>\n"; for ($i = $rackData['height']; $i > 5; $i--) { if ($i == 40) { echo "<tr><td>top</td><td>{$row['top']}</td></tr>\n"; } else { if ($i == 23) { echo "<tr><td>middle</td><td>{$row['middle']}</td></tr>\n"; } else { if ($i == 11) { echo "<tr><td>bottom</td><td>{$row['bottom']}</td></tr>\n"; } else { echo "<tr><td> </td><td> </td></tr>\n"; } } } } echo "</table>"; } echo "<table class=rack align=center border=0 cellspacing=0 cellpadding=1>\n"; echo "<tr><th width='10%'> </th><th width='20%'>Front</th>"; echo "<th width='50%'>Interior</th><th width='20%'>Back</th></tr>\n"; for ($i = $rackData['height']; $i > 0; $i--) { echo "<tr><th>" . inverseRackUnit($i, $rackData) . "</th>"; for ($locidx = 0; $locidx < 3; $locidx++) { if (isset($rackData[$i][$locidx]['skipped'])) { continue; } $state = $rackData[$i][$locidx]['state']; echo "<td class='atom state_{$state}"; if (isset($rackData[$i][$locidx]['hl'])) { echo $rackData[$i][$locidx]['hl']; } echo "'"; if (isset($rackData[$i][$locidx]['colspan'])) { echo ' colspan=' . $rackData[$i][$locidx]['colspan']; } if (isset($rackData[$i][$locidx]['rowspan'])) { echo ' rowspan=' . $rackData[$i][$locidx]['rowspan']; } echo ">"; switch ($state) { case 'T': printObjectDetailsForRenderRack($rackData[$i][$locidx]['object_id'], $hl_obj_id); break; case 'A': echo '<div title="This rackspace does not exist"> </div>'; break; case 'F': echo '<div title="Free rackspace"> </div>'; break; case 'U': echo '<div title="Problematic rackspace, you CAN\'T mount here"> </div>'; break; default: echo '<div title="No data"> </div>'; break; } echo '</td>'; } echo "</tr>\n"; } echo "</table>\n"; // Get a list of all of objects Zero-U mounted to this rack $zeroUObjects = getEntityRelatives('children', 'rack', $rack_id); if (count($zeroUObjects) > 0) { echo "<br><table width='75%' class=rack border=0 cellspacing=0 cellpadding=1>\n"; echo "<tr><th>Zero-U:</th></tr>\n"; foreach ($zeroUObjects as $zeroUObject) { $state = $zeroUObject['entity_id'] == $hl_obj_id ? 'Th' : 'T'; echo "<tr><td class='atom state_{$state}'>"; printObjectDetailsForRenderRack($zeroUObject['entity_id']); echo "</td></tr>\n"; } echo "</table>\n"; } echo "</center>\n"; }
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 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 _printUnLinkPort($src_port_id, &$dst_link, $linktype) { global $lm_cache; if ($linktype == 'front' && !$lm_cache['allowlink']) { return; } if ($linktype != 'front' && !$lm_cache['allowbacklink']) { return; } $src_port = $this->list[$src_port_id]; $dst_port = $this->list[$dst_link['id']]; /* use RT unlink for front link, linkmgmt unlink for back links */ if ($linktype == 'back') { $tab = 'linkmgmt'; } else { $tab = 'ports'; } return '<a href=' . makeHrefProcess(array('op' => 'unlinkPort', 'port_id' => $src_port_id, 'remote_id' => $dst_port['id'], 'object_id' => $this->object_id, 'tab' => $tab, 'linktype' => $linktype)) . ' onclick="return confirm(\'unlink ports ' . $src_port['name'] . ' -> ' . $dst_port['name'] . ' (' . $linktype . ') with cable ID: ' . $dst_link['cable'] . '?\');">' . getImageHREF('cut', $linktype . ' Unlink this port') . '</a>'; }
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 serializeFileLinks($links, $scissors = FALSE) { $comma = ''; $ret = ''; foreach ($links as $link_id => $li) { switch ($li['entity_type']) { case 'ipv4net': $params = "page=ipv4net&id="; break; case 'ipv6net': $params = "page=ipv6net&id="; break; case 'ipv4rspool': $params = "page=ipv4rspool&pool_id="; break; case 'ipv4vs': $params = "page=ipv4vs&vs_id="; break; case 'object': $params = "page=object&object_id="; break; case 'rack': $params = "page=rack&rack_id="; break; case 'location': $params = "page=location&location_id="; break; case 'user': $params = "page=user&user_id="; break; } $ret .= $comma; if ($scissors) { $ret .= "<a href='" . makeHrefProcess(array('op' => 'unlinkFile', 'link_id' => $link_id)) . "'"; $ret .= getImageHREF('cut') . '</a> '; } $ret .= sprintf("<a href='index.php?%s%s'>%s</a>", $params, $li['entity_id'], $li['name']); $comma = '<br>'; } return $ret; }
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>'; }