function renderObject($object_id) { global $nextorder, $virtual_obj_types; $info = spotEntity('object', $object_id); amplifyCell($info); // Main layout starts. echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>"; echo "<tr><td colspan=2 align=center><h1>{$info['dname']}</h1></td></tr>\n"; // left column with uknown number of portlets echo "<tr><td class=pcleft>"; // display summary portlet $summary = array(); if (strlen($info['name'])) { $summary['Common name'] = $info['name']; } elseif (considerConfiguredConstraint($info, 'NAMEWARN_LISTSRC')) { $summary[] = array('<tr><td colspan=2 class=msg_error>Common name is missing.</td></tr>'); } $summary['Object type'] = '<a href="' . makeHref(array('page' => 'depot', 'tab' => 'default', 'cfe' => '{$typeid_' . $info['objtype_id'] . '}')) . '">' . decodeObjectType($info['objtype_id']) . '</a>'; if (strlen($info['label'])) { $summary['Visible label'] = $info['label']; } if (strlen($info['asset_no'])) { $summary['Asset tag'] = $info['asset_no']; } elseif (considerConfiguredConstraint($info, 'ASSETWARN_LISTSRC')) { $summary[] = array('<tr><td colspan=2 class=msg_error>Asset tag is missing.</td></tr>'); } $parents = getParents($info, 'object'); // lookup the human-readable object type, sort by it foreach ($parents as $parent_id => $parent) { $parents[$parent_id]['object_type'] = decodeObjectType($parent['objtype_id']); } $grouped_parents = groupBy($parents, 'object_type'); ksort($grouped_parents); foreach ($grouped_parents as $parents_group) { uasort($parents_group, 'compare_name'); $label = $parents_group[key($parents_group)]['object_type'] . (count($parents_group) > 1 ? ' containers' : ' container'); $fmt_parents = array(); foreach ($parents_group as $parent) { $fmt_parents[] = mkCellA($parent); } $summary[$label] = implode('<br>', $fmt_parents); } $children = getChildren($info, 'object'); foreach (groupBy($children, 'objtype_id') as $objtype_id => $children_group) { uasort($children_group, 'compare_name'); $fmt_children = array(); foreach ($children_group as $child) { $fmt_children[] = mkCellA($child); } $summary["Contains " . strtolower(decodeObjectType($objtype_id))] = implode('<br>', $fmt_children); } if ($info['has_problems'] == 'yes') { $summary[] = array('<tr><td colspan=2 class=msg_error>Has problems</td></tr>'); } foreach (getAttrValuesSorted($object_id) as $record) { if (strlen($record['value']) and permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $record['id'])))) { $summary['{sticker}' . $record['name']] = formatAttributeValue($record); } } $summary[] = array(getOutputOf('printTagTRs', $info, makeHref(array('page' => 'depot', 'tab' => 'default', 'andor' => 'and', 'cfe' => '{$typeid_' . $info['objtype_id'] . '}')) . "&")); renderEntitySummary($info, 'summary', $summary); if (strlen($info['comment'])) { startPortlet('Comment'); echo '<div class=commentblock>' . string_insert_hrefs($info['comment']) . '</div>'; finishPortlet(); } $logrecords = getLogRecordsForObject($_REQUEST['object_id']); if (count($logrecords)) { startPortlet('log records'); echo "<table cellspacing=0 cellpadding=5 align=center class=widetable width='100%'>"; $order = 'odd'; foreach ($logrecords as $row) { echo "<tr class=row_{$order} valign=top>"; echo '<td class=tdleft>' . $row['date'] . '<br>' . $row['user'] . '</td>'; echo '<td class="logentry">' . string_insert_hrefs(htmlspecialchars($row['content'], ENT_NOQUOTES)) . '</td>'; echo '</tr>'; $order = $nextorder[$order]; } echo '</table>'; finishPortlet(); } switchportInfoJS($object_id); // load JS code to make portnames interactive renderFilesPortlet('object', $object_id); if (count($info['ports'])) { startPortlet('ports and links'); $hl_port_id = 0; if (isset($_REQUEST['hl_port_id'])) { assertUIntArg('hl_port_id'); $hl_port_id = $_REQUEST['hl_port_id']; addAutoScrollScript("port-{$hl_port_id}"); } echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>"; echo '<tr><th class=tdleft>Local name</th><th class=tdleft>Visible label</th>'; echo '<th class=tdleft>Interface</th><th class=tdleft>L2 address</th>'; echo '<th class=tdcenter colspan=2>Remote object and port</th>'; echo '<th class=tdleft>Cable ID</th></tr>'; foreach ($info['ports'] as $port) { callHook('renderObjectPortRow', $port, $hl_port_id == $port['id']); } if (permitted(NULL, 'ports', 'set_reserve_comment')) { addJS('js/inplace-edit.js'); } echo "</table><br>"; finishPortlet(); } if (count($info['ipv4']) + count($info['ipv6'])) { startPortlet('IP addresses'); echo "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>\n"; if (getConfigVar('EXT_IPV4_VIEW') == 'yes') { echo "<tr class=tdleft><th>OS interface</th><th>IP address</th><th>network</th><th>routed by</th><th>peers</th></tr>\n"; } else { echo "<tr class=tdleft><th>OS interface</th><th>IP address</th><th>peers</th></tr>\n"; } // group IP allocations by interface name instead of address family $allocs_by_iface = array(); foreach (array('ipv4', 'ipv6') as $ip_v) { foreach ($info[$ip_v] as $ip_bin => $alloc) { $allocs_by_iface[$alloc['osif']][$ip_bin] = $alloc; } } // sort allocs array by portnames foreach (sortPortList($allocs_by_iface) as $iface_name => $alloclist) { $is_first_row = TRUE; foreach ($alloclist as $alloc) { $rendered_alloc = callHook('getRenderedAlloc', $object_id, $alloc); echo "<tr class='{$rendered_alloc['tr_class']}' valign=top>"; // display iface name, same values are grouped into single cell if ($is_first_row) { $rowspan = count($alloclist) > 1 ? 'rowspan="' . count($alloclist) . '"' : ''; echo "<td class=tdleft {$rowspan}>" . $iface_name . $rendered_alloc['td_name_suffix'] . "</td>"; $is_first_row = FALSE; } echo $rendered_alloc['td_ip']; if (getConfigVar('EXT_IPV4_VIEW') == 'yes') { echo $rendered_alloc['td_network']; echo $rendered_alloc['td_routed_by']; } echo $rendered_alloc['td_peers']; echo "</tr>\n"; } } echo "</table><br>\n"; finishPortlet(); } $forwards = $info['nat4']; if (count($forwards['in']) or count($forwards['out'])) { startPortlet('NATv4'); if (count($forwards['out'])) { echo "<h3>locally performed NAT</h3>"; echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; echo "<tr><th>Proto</th><th>Match endpoint</th><th>Translate to</th><th>Target object</th><th>Rule comment</th></tr>\n"; foreach ($forwards['out'] as $pf) { $class = 'trerror'; $osif = ''; $localip_bin = ip_parse($pf['localip']); if (array_key_exists($localip_bin, $info['ipv4'])) { $class = $info['ipv4'][$localip_bin]['addrinfo']['class']; $osif = $info['ipv4'][$localip_bin]['osif'] . ': '; } echo "<tr class='{$class}'>"; echo "<td>{$pf['proto']}</td><td class=tdleft>{$osif}" . getRenderedIPPortPair($pf['localip'], $pf['localport']) . "</td>"; echo "<td class=tdleft>" . getRenderedIPPortPair($pf['remoteip'], $pf['remoteport']) . "</td>"; $address = getIPAddress(ip4_parse($pf['remoteip'])); echo "<td class='description'>"; if (count($address['allocs'])) { foreach ($address['allocs'] as $bond) { echo mkA("{$bond['object_name']}({$bond['name']})", 'object', $bond['object_id']) . ' '; } } elseif (strlen($pf['remote_addr_name'])) { echo '(' . $pf['remote_addr_name'] . ')'; } echo "</td><td class='description'>{$pf['description']}</td></tr>"; } echo "</table><br><br>"; } if (count($forwards['in'])) { echo "<h3>arriving NAT connections</h3>"; echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center'>\n"; echo "<tr><th>Matched endpoint</th><th>Source object</th><th>Translated to</th><th>Rule comment</th></tr>\n"; foreach ($forwards['in'] as $pf) { echo "<tr>"; echo "<td>{$pf['proto']}/" . getRenderedIPPortPair($pf['localip'], $pf['localport']) . "</td>"; echo '<td class="description">' . mkA($pf['object_name'], 'object', $pf['object_id']); echo "</td><td>" . getRenderedIPPortPair($pf['remoteip'], $pf['remoteport']) . "</td>"; echo "<td class='description'>{$pf['description']}</td></tr>"; } echo "</table><br><br>"; } finishPortlet(); } renderSLBTriplets2($info); renderSLBTriplets($info); echo "</td>\n"; // After left column we have (surprise!) right column with rackspace portlet only. echo "<td class=pcright>"; if (!in_array($info['objtype_id'], $virtual_obj_types)) { // rackspace portlet startPortlet('rackspace allocation'); foreach (getResidentRacksData($object_id, FALSE) as $rack_id) { renderRack($rack_id, $object_id); } echo '<br>'; finishPortlet(); } echo "</td></tr>"; echo "</table>\n"; }
public function wtf() { $wtf = DB::table('aboutusregions')->join('aboutus', 'aboutusregions.id', '=', 'aboutus.where_eng')->where('aboutus.status', '=', 'live')->aboutus . groupBy('where_eng')->distinct()->get(); return $wtf; }
/** * Get the poker ranks and every rank times. * * @return array */ public function getRanksAndTimesByHand($hand) { if (count($hand) < 5) { throw new InvalidArgumentException("Hand must have 5 or 5+ pokers"); } $ranks = map($hand, function ($card) { return strpos($this->orders, $card[0]); }); list($ranks, $times, $origin) = groupBy($ranks); if ($ranks == [14, 5, 4, 3, 2]) { $ranks = [5, 4, 3, 2, 1]; } return [$ranks, $times, $origin]; }