function NagiosTabHandler() { global $nagios_user, $nagios_password, $nagios_url; # Load object data assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); $nagios_url_cgi = $nagios_url . '/cgi-bin/status.cgi?host=%%NAGIOS%%'; $nagios_url_cgi = str_replace("%%NAGIOS%%", urlencode($object['name']), $nagios_url_cgi); # Curl request $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $nagios_url_cgi); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "{$nagios_user}:{$nagios_password}"); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); # Remove unwanted tags & headline & hyperlinks $output = strip_tags($output, '<p><div><table><tr><td><th><br><a>'); $output = substr($output, strpos($output, '<')); $output = str_replace("HREF='", "onclick='return popup(this.href);' target='_blank' HREF='{$nagios_url}/cgi-bin/", $output); $output = str_replace("href='", "onclick='return popup(this.href);' target='_blank' href='{$nagios_url}/cgi-bin/", $output); $output = str_replace($nagios_url . "/cgi-bin/http://www.nagios.org", "http://www.nagios.org", $output); # Output htmlExtras(); echo '<div class=portlet><h2>Nagios</h2>' . $output . '</div>'; }
function localtrigger_Link2Nagios() { global $noNagiosCheck; assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); if (!in_array($object['objtype_id'], $noNagiosCheck)) { $trigger = getNagiosState($object['name']); return $trigger; } else { return ''; } }
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"; }
$chapters = getChapterList(); if (!isset($chapters[$_REQUEST['chapter_no']])) { throw new InvalidArgException('chapter_no', $_REQUEST['chapter_no'], "invalid argument: no such chapter"); } usePreparedInsertBlade('Dictionary', array('chapter_id' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value'])); sendAPIResponse(array(), array('message' => 'dictionary entry added successfully', 'chapter_no' => $_REQUEST['chapter_no'])); break; // delete an entry from a chapter // UI equivalent: /index.php?page=chapter&module=redirect&op=del&dict_key=50228&tab=edit&chapter_no=10007 // UI handler: tableHandler() // delete an entry from a chapter // UI equivalent: /index.php?page=chapter&module=redirect&op=del&dict_key=50228&tab=edit&chapter_no=10007 // UI handler: tableHandler() case 'delete_chapter_entry': require_once 'inc/init.php'; assertUIntArg('chapter_no', TRUE); assertStringArg('dict_value', TRUE); // make sure the chapter exists $chapters = getChapterList(); if (!isset($chapters[$_REQUEST['chapter_no']])) { throw new InvalidArgException('chapter_no', $_REQUEST['chapter_no'], "invalid argument: no such chapter"); } // make sure the entry exists in this chapter $words = readChapter($_REQUEST['chapter_no'], 'o'); if (!in_array($_REQUEST['dict_value'], $words)) { throw new InvalidArgException('dict_value', $_REQUEST['dict_value'], "invalid argument: no such value in chapter ID " . $_REQUEST['chapter_no']); } usePreparedDeleteBlade('Dictionary', array('chapter_id' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value'])); sendAPIResponse(array(), array('message' => 'dictionary entry deleted successfully', 'chapter_no' => $_REQUEST['chapter_no'], 'dict_value' => $_REQUEST['dict_value'])); break; // perform a generic search
function localtrigger_PortLinker() { global $portLinkerObjectTypes; assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); if (in_array($object['objtype_id'], $portLinkerObjectTypes)) { $linkok = localpretrigger_PortLinker(); } else { $linkok = 0; } if ($linkok == 2) { return 1; } else { return ''; } }
function localexecute_PortGenerator() { global $errorText, $portList; $linkok = localtrigger_PortGenerator(); if ($linkok) { assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); if (localverify_PortGenerator($object)) { $cnt = 0; foreach ($portList as $aPort) { commitAddPort($_REQUEST['object_id'], $aPort['name'], $aPort['port_id'], $aPort['label'], ""); $cnt++; } } } else { $errorText = "Port generator not allowed"; } if ($linkok) { //return buildRedirectURL (__FUNCTION__, 'OK', array ("Successfully added {$cnt} ports")); return setMessage('success', $message = "Successfully added {$cnt} ports"); } else { //return buildRedirectURL (__FUNCTION__, 'ERR', array ("Error adding the ports ({$errorText})")); return setMessage('error', $message = "Error adding the ports ({$errorText})"); } }
function doVSMigrate() { global $dbxlink; $vs_id = assertUIntArg('vs_id'); $vs_cell = spotEntity('ipvs', $vs_id); amplifyCell($vs_cell); $tag_ids = genericAssertion('taglist', 'array0'); $old_vs_list = genericAssertion('vs_list', 'array'); $plan = callHook('buildVSMigratePlan', $vs_id, $old_vs_list); $dbxlink->beginTransaction(); // remove all triplets usePreparedDeleteBlade('VSEnabledIPs', array('vs_id' => $vs_id)); usePreparedDeleteBlade('VSEnabledPorts', array('vs_id' => $vs_id)); // remove all VIPs and ports that are in $plan and create new ones foreach ($plan['vips'] as $vip) { usePreparedDeleteBlade('VSIPs', array('vs_id' => $vs_id, 'vip' => $vip['vip'])); usePreparedInsertBlade('VSIPs', array('vs_id' => $vs_id) + $vip); } foreach ($plan['ports'] as $port) { usePreparedDeleteBlade('VSPorts', array('vs_id' => $vs_id, 'proto' => $port['proto'], 'vport' => $port['vport'])); usePreparedInsertBlade('VSPorts', array('vs_id' => $vs_id) + $port); } // create triplets foreach ($plan['triplets'] as $triplet) { $tr_key = array('vs_id' => $triplet['vs_id'], 'object_id' => $triplet['object_id'], 'rspool_id' => $triplet['rspool_id']); foreach ($triplet['ports'] as $port) { addSLBPortLink($tr_key + $port); } foreach ($triplet['vips'] as $vip) { addSLBIPLink($tr_key + $vip); } } // update configs usePreparedUpdateBlade('VS', $plan['properties'], array('id' => $vs_id)); // replace tags global $taglist; $chain = array(); foreach ($tag_ids as $tid) { if (!isset($taglist[$tid])) { $dbxlink->rollback(); showError("Unknown tag id {$tid}"); } else { $chain[] = $taglist[$tid]; } } rebuildTagChainForEntity('ipvs', $vs_id, $chain, TRUE); $dbxlink->commit(); showSuccess("old VS configs were copied to VS group"); return buildRedirectURL(NULL, 'default'); }
function getTripletConfigAJAX() { $tr_list = fetchTripletRows(array('object_id' => assertUIntArg('object_id'), 'vs_id' => assertUIntArg('vs_id'), 'rspool_id' => assertUIntArg('rspool_id'))); echo '<div class="slbconf" style="max-height: 500px; max-width: 600px; overflow: auto">' . htmlspecialchars(generateSLBConfig2($tr_list)) . '</div>'; }
function updateVLANDomain() { $domain_id = assertUIntArg('vdom_id'); $group_id = assertUIntArg('group_id', TRUE); $description = assertStringArg('vdom_descr'); if (!$group_id) { $group_id = NULL; } else { $dominfo = getVLANDomain($domain_id); $parent_dominfo = getVLANDomain($group_id); if ($group_id == $domain_id) { throw new InvalidRequestArgException('group_id', $group_id, "domains should not be the same"); } if ($parent_dominfo['group_id'] || $dominfo['subdomc']) { throw new InvalidRequestArgException('group_id', $group_id, "Multi-level domain groups are not allowed"); } } usePreparedUpdateBlade('VLANDomain', array('group_id' => $group_id, 'description' => $description), array('id' => $domain_id)); showSuccess("VLAN domain updated successfully"); }
function linkmgmt_renderPopupPortSelector() { global $lm_multilink_port_types; assertUIntArg('port'); $port_id = $_REQUEST['port']; $showlinktypeswitch = false; if (isset($_GET['linktype'])) { $linktype = $_GET['linktype']; } else { $linktype = 'front'; } if ($linktype == 'both') { /* * use POST front/back_view to set linktype * and show linktype switch button */ $showlinktypeswitch = true; if (isset($_POST['front_view'])) { $linktype = 'front'; } else { if (isset($_POST['back_view'])) { $linktype = 'back'; } else { $linktype = 'front'; } } } // portlist::var_dump_html($_POST); $portcompat = true; if ($linktype == 'back') { if (isset($_POST['portcompat'])) { $portcompat = $_POST['portcompat']; } } $object_id = $_REQUEST['object_id']; $port_info = getPortInfo($port_id); $multilink = LM_MULTILINK && $linktype == 'back' && in_array($port_info['oif_id'], $lm_multilink_port_types); if (isset($_REQUEST['in_rack'])) { $in_rack = $_REQUEST['in_rack'] != 'off'; } else { $in_rack = true; } // portlist::var_dump_html($port_info); // portlist::var_dump_html($_GET); // portlist::var_dump_html($_POST); // fill port filter structure $filter = array('racks' => array(), 'objects' => '', 'object_id' => '', 'ports' => ''); $remote_object = NULL; if (isset($_REQUEST['remote_object'])) { $remote_object = $_REQUEST['remote_object']; if ($remote_object != 'NULL') { $filter['object_id'] = $remote_object; } } if (isset($_REQUEST['filter-obj'])) { $filter['objects'] = $_REQUEST['filter-obj']; } if (isset($_REQUEST['filter-port'])) { $filter['ports'] = $_REQUEST['filter-port']; } if ($in_rack) { $object = spotEntity('object', $port_info['object_id']); if ($object['rack_id']) { $filter['racks'] = getProximateRacks($object['rack_id'], getConfigVar('PROXIMITY_RANGE')); } } $objectlist = array('NULL' => '- Show All -'); $objectlist = $objectlist + linkmgmt_findSparePorts($port_info, $filter, $linktype, $multilink, true, false, $portcompat); $spare_ports = linkmgmt_findSparePorts($port_info, $filter, $linktype, $multilink, false, false, $portcompat); $maxsize = getConfigVar('MAXSELSIZE'); $objectcount = count($objectlist); if ($linktype == 'back') { $notlinktype = 'front'; } else { $notlinktype = 'back'; } // display search form echo 'Link ' . $linktype . ' of ' . formatPort($port_info) . ' to...'; echo '<form method=POST>'; startPortlet($linktype . ' Port list filter'); // echo '<input type=hidden name="module" value="popup">'; // echo '<input type=hidden name="helper" value="portlist">'; echo '<input type=hidden name="port" value="' . $port_id . '">'; echo '<table><tr><td valign="top"><table><tr><td>'; echo '<table align="center"><tr>'; // echo '<td nowrap="nowrap"><input type="hidden" name="linktype" value="front" /><input type="checkbox" name="linktype" value="back"'.($linktype == 'back' ? ' checked="checked"' : '' ).'>link backend</input></td></tr><tr>'; echo '<td class="tdleft"><label>Object name:<br><input type=text size=8 name="filter-obj" value="' . htmlspecialchars($filter['objects'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft"><label>Port name:<br><input type=text size=6 name="filter-port" value="' . htmlspecialchars($filter['ports'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft" valign="bottom"><input type="hidden" name="in_rack" value="off" /><label><input type=checkbox value="1" name="in_rack"' . ($in_rack ? ' checked="checked"' : '') . ' onchange="this.form.submit();">Nearest racks</label></td>'; echo '</tr></table>'; echo '</td></tr><tr><td>'; echo 'Object name (count ports)<br>'; echo getSelect($objectlist, array('name' => 'remote_object', 'size' => $objectcount <= $maxsize ? $objectcount : $maxsize), $remote_object, FALSE); echo '</td></tr></table></td>'; echo '<td valign="top"><table><tr><td><input type=submit value="update objects / ports"></td></tr>'; if ($showlinktypeswitch) { echo '<tr height=150px><td><input type=submit value="Switch to ' . $notlinktype . ' view" name="' . $notlinktype . '_view"></tr></td>'; } if ($linktype == 'back') { echo '<input type="hidden" name="portcompat" value="0">'; echo '<tr height=150px><td><input type=checkbox onchange="this.form.submit();" name="portcompat"' . ($portcompat ? 'checked="checked" ' : '') . 'value="1">Port Compatibility</input></tr></td>'; echo '<input type="hidden" name="back_view">'; } echo '</table></td>'; finishPortlet(); echo '</td><td>'; // display results startPortlet('Compatible spare ' . $linktype . ' ports'); echo "spare {$linktype} Object:Port -- {$notlinktype} cableID --> {$notlinktype} Port:Object<br>"; if ($multilink) { echo "Multilink<br>"; } if (empty($spare_ports)) { echo '(nothing found)'; } else { $linkcount = count($spare_ports); $options = array('name' => 'remote_ports[]', 'size' => getConfigVar('MAXSELSIZE'), 'size' => $linkcount <= $maxsize ? $linkcount : $maxsize); if ($multilink) { $options['multiple'] = 'multiple'; } echo getSelect($spare_ports, $options, NULL, FALSE); echo "<p>{$linktype} Cable ID: <input type=text id=cable name=cable>"; echo "<p><input type='submit' value='Link {$linktype}' name='do_link'>"; } finishPortlet(); echo '</td></tr></table>'; echo '</form>'; }
function cloneRSPool() { assertUIntArg('pool_id'); $pool = spotEntity('ipv4rspool', $_REQUEST['pool_id']); $rs_list = getRSListInPool($pool['id']); $tagidlist = array(); foreach ($pool['etags'] as $taginfo) { $tagidlist[] = $taginfo['id']; } $new_id = commitCreateRSPool($pool['name'] . ' (copy)', $pool['vsconfig'], $pool['rsconfig'], $tagidlist); foreach ($rs_list as $rs) { addRStoRSPool($new_id, $rs['rsip_bin'], $rs['rsport'], $rs['inservice'], $rs['rsconfig'], $rs['comment']); } showSuccess("Created a copy of pool <a href='" . makeHref(array('page' => 'ipv4rspool', 'tab' => 'default', 'pool_id' => $pool['id'])) . "'>{$pool['name']}</a>"); return buildRedirectURL('ipv4rspool', 'default', array('pool_id' => $new_id)); }
function copyLotOfObjects() { global $dbxlink; $dbrollback = 0; if (!$dbxlink->beginTransaction()) { throw new RTDatabaseError("can not start transaction"); } // do we need this ? $log = emptyLog(); $taglist = isset($_REQUEST['taglist']) ? $_REQUEST['taglist'] : array(); assertUIntArg('global_type_id', TRUE); assertStringArg('namelist', TRUE); $global_type_id = $_REQUEST['global_type_id']; $source_object_id = $_REQUEST['object_id']; $source_object = spotEntity('object', $source_object_id); amplifyCell($source_object); // only call amplifyCell_object_Backend_Port if we have function linkmgmt_linkPorts from linkmgmt.php if (function_exists('amplifyCell_object_Backend_Port') && function_exists('linkmgmt_linkPorts')) { amplifyCell_object_Backend_Port($source_object); } if ($global_type_id == 0 or !strlen($_REQUEST['namelist'])) { // Log something reasonable with showError Here // We do not have names to copy our object to ! // Pls check what makes $global_type_id == 0 an error $log = mergeLogs($log, oneLiner(186)); return; } // The name extractor below was stolen from ophandlers.php:addMultiPorts() $names1 = explode("\n", $_REQUEST['namelist']); $names2 = array(); foreach ($names1 as $line) { $parts = explode('\\r', $line); reset($parts); if (!strlen($parts[0])) { continue; } else { $names2[] = rtrim($parts[0]); } } foreach ($names2 as $name_or_csv) { $label = ''; $asset_no = ''; $object_name = ''; $regexp = '/^\\"([^\\"]*)\\","([^\\"]*)\\","([^\\"]*)\\"/'; $object_name_or_csv = htmlspecialchars_decode($name_or_csv, ENT_QUOTES); // error_log( "$regexp $object_name" ); if (preg_match($regexp, $object_name_or_csv, $matches)) { $object_name = $matches[1]; $label = $matches[2]; $asset_no = $matches[3]; } else { $object_name = $name_or_csv; } try { $object_id = commitAddObject($object_name, $label, $global_type_id, $asset_no, $taglist); if (!$object_id) { throw new RTDatabaseError("could not create {$object_name}"); } $info = spotEntity('object', $object_id); amplifyCell($info); foreach ($source_object['ports'] as $source_port) { $update_port = 0; foreach ($info['ports'] as $new_port) { if ($new_port['name'] == $source_port['name']) { commitUpdatePort($object_id, $new_port['id'], $new_port['name'], $new_port['oif_id'], $source_port['label'], ""); $update_port = 1; } } if ($update_port) { true; } else { commitAddPort($object_id, $source_port['name'], sprintf("%s-%s", $source_port['iif_id'], $source_port['oif_id']), $source_port['label'], ""); } } // Copy Backendlinks only start if we ghave function linkmgmt_linkPorts from linkmgmt.php if (function_exists('amplifyCell_object_Backend_Port') && function_exists('linkmgmt_linkPorts')) { $info = spotEntity('object', $object_id); amplifyCell($info); amplifyCell_object_Backend_Port($info); /* showError( '<div align="left"><pre>\n===== Source Object ======\n\n' . varDumpToString ( $source_object ) . '\n\n===== New Object ======\n\n' . varDumpToString ( $info ) . '</pre></div>' ); */ $name_by_id = array(); foreach ($info['BackendPorts'] as $new_be_port) { $name_by_id[$new_be_port['name']] = $new_be_port['id']; } $linked_ports = array(); foreach ($source_object['BackendPorts'] as $source_be_port) { if ($source_be_port['object_id'] == $source_be_port['remote_object_id']) { // We have a Port that has the own object as remote object we want to copy this type of Linko // We have backend Links $new_be_port_a = $name_by_id[$source_be_port['name']]; $new_be_port_b = $name_by_id[$source_be_port['remote_name']]; if ($new_be_port_a && $new_be_port_b && !array_key_exists($new_be_port_a, $linked_ports) && !array_key_exists($new_be_port_b, $linked_ports)) { // error_log ( sprintf ('new_be_port_a %s // new_be_port_b %s // cableid %s', $new_be_port_a , $new_be_port_b, $source_be_port['cableid'] )); $ret_val = linkmgmt_linkPorts($new_be_port_a, $new_be_port_b, 'back', $source_be_port['cableid']); // error_log ( sprintf (' linkmgmt_linkPorts ret val: "%s" ', $ret_val)) ; if ($ret_val) { throw new RTDatabaseError("could not copy Backend Links for {$object_name} because: {$ret_val}"); } else { $linked_ports[$new_be_port_a] = True; $linked_ports[$new_be_port_b] = True; } } } } } // Copy attributes foreach (getAttrValues($source_object_id) as $record) { $value = $record['value']; switch ($record['type']) { case 'uint': case 'float': case 'string': $value = $record['value']; break; case 'dict': $value = $record['key']; break; default: } if (permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $record['id'])))) { if (empty($value)) { commitUpdateAttrValue($object_id, $record['id']); } else { commitUpdateAttrValue($object_id, $record['id'], $value); } } else { showError('Permission denied, "' . $record['name'] . '" can not be set'); } } //$log = mergeLogs ($log, oneLiner (5, array ('<a href="' . // makeHref (array ('page' => 'object', 'tab' => 'default', 'object_id' => $object_id)) . // '">' . $info['dname'] . '</a>')) //); showSuccess(sprintf("Copied Object %s ; new Object: %s", $source_object['name'], formatPortLink($object_id, $info['dname'], 1, '', ''))); } catch (RTDatabaseError $e) { error_log("rolling back DB"); $dbrollback = 1; $dbxlink->rollBack(); $log = mergeLogs($log, oneLiner(147, array($object_name))); throw new RTDatabaseError($e->getMessage() . sprintf(' (%s)', $name_or_csv)); } } if (!$dbrollback) { $dbxlink->commit(); } // return buildWideRedirectURL ($log); }
function renderPopupPortSelector() { assertUIntArg('port'); $port_id = $_REQUEST['port']; $port_info = getPortInfo($port_id); $in_rack = isCheckSet('in_rack'); // fill port filter structure $filter = array('racks' => array(), 'objects' => '', 'ports' => ''); if (isset($_REQUEST['filter-obj'])) { $filter['objects'] = trim($_REQUEST['filter-obj']); } if (isset($_REQUEST['filter-port'])) { $filter['ports'] = trim($_REQUEST['filter-port']); } if ($in_rack) { $object = spotEntity('object', $port_info['object_id']); if ($object['rack_id']) { $filter['racks'] = getProximateRacks($object['rack_id'], getConfigVar('PROXIMITY_RANGE')); } } $spare_ports = array(); if (!empty($filter['racks']) || !empty($filter['objects']) || !empty($filter['ports'])) { $spare_ports = findSparePorts($port_info, $filter); } // display search form echo 'Link ' . formatPort($port_info) . ' to...'; echo '<form method=GET>'; startPortlet('Port list filter'); echo '<input type=hidden name="module" value="popup">'; echo '<input type=hidden name="helper" value="portlist">'; echo '<input type=hidden name="port" value="' . $port_id . '">'; echo '<table align="center" valign="bottom"><tr>'; echo '<td class="tdleft"><label>Object name:<br><input type=text size=8 name="filter-obj" value="' . htmlspecialchars($filter['objects'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft"><label>Port name:<br><input type=text size=6 name="filter-port" value="' . htmlspecialchars($filter['ports'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft" valign="bottom"><label><input type=checkbox name="in_rack"' . ($in_rack ? ' checked' : '') . '>Nearest racks</label></td>'; echo '<td valign="bottom"><input type=submit value="show ports"></td>'; echo '</tr></table>'; finishPortlet(); // display results startPortlet('Compatible spare ports'); if (empty($spare_ports)) { echo '(nothing found)'; } else { echo getSelect($spare_ports, array('name' => 'remote_port', 'size' => getConfigVar('MAXSELSIZE')), NULL, FALSE); echo "<p>Cable ID: <input type=text id=cable name=cable>"; echo "<p><input type='submit' value='Link' name='do_link'>"; } finishPortlet(); echo '</form>'; }
function updateNodePingCheck() { assertUIntArg('check_id'); assertUIntArg('account_id'); assertStringArg('np_check_id'); $check = getNodePingCheck($_REQUEST['check_id']); $account = getNodePingAccount($_REQUEST['account_id']); $nodeping = new NodePingClient(array('token' => $account['token'])); $np_check = $nodeping->check->get(array('id' => $_REQUEST['np_check_id'], 'limit' => 1, 'clean' => true)); if (isset($check['error'])) { return showFuncMessage(__FUNCTION__, 'ERR1', array('Error: ' . $np_check['error'])); } usePreparedUpdateBlade('NodePingCheck', array('account_id' => $_REQUEST['account_id'], 'np_check_id' => $_REQUEST['np_check_id'], 'label' => $np_check['label'], 'type' => $np_check['type'], 'target' => $np_check['parameters']['target'], 'check_interval' => $np_check['interval']), array('id' => $_REQUEST['check_id'])); return showFuncMessage(__FUNCTION__, 'OK', array(htmlspecialchars($np_check['label']))); }
function renderDiscoveredNeighbors($object_id) { global $tabno; $opcode_by_tabno = array('livecdp' => 'getcdpstatus', 'livelldp' => 'getlldpstatus'); try { $neighbors = queryDevice($object_id, $opcode_by_tabno[$tabno]); $neighbors = sortPortList($neighbors); } catch (RTGatewayError $e) { showError($e->getMessage()); return; } $mydevice = spotEntity('object', $object_id); amplifyCell($mydevice); // reindex by port name $myports = array(); foreach ($mydevice['ports'] as $port) { if (mb_strlen($port['name'])) { $myports[$port['name']][] = $port; } } // scroll to selected port if (isset($_REQUEST['hl_port_id'])) { assertUIntArg('hl_port_id'); $hl_port_id = intval($_REQUEST['hl_port_id']); addAutoScrollScript("port-{$hl_port_id}"); } switchportInfoJS($object_id); // load JS code to make portnames interactive printOpFormIntro('importDPData'); echo '<br><table cellspacing=0 cellpadding=5 align=center class=widetable>'; echo '<tr><th colspan=2>local port</th><th></th><th>remote device</th><th colspan=2>remote port</th><th><input type="checkbox" checked id="cb-toggle"></th></tr>'; $inputno = 0; foreach ($neighbors as $local_port => $remote_list) { $initial_row = TRUE; // if port has multiple neighbors, the first table row is initial // array of local ports with the name specified by DP $local_ports = isset($myports[$local_port]) ? $myports[$local_port] : array(); foreach ($remote_list as $dp_neighbor) { $error_message = NULL; $link_matches = FALSE; $portinfo_local = NULL; $portinfo_remote = NULL; $variants = array(); do { // once-cyle fake loop used only to break out of it if (!empty($local_ports)) { $portinfo_local = $local_ports[0]; } // find remote object by DP information $dp_remote_object_id = searchByMgmtHostname($dp_neighbor['device']); if (!$dp_remote_object_id) { $dp_remote_object_id = lookupEntityByString('object', $dp_neighbor['device']); } if (!$dp_remote_object_id) { $error_message = "No such neighbor <i>{$dp_neighbor['device']}</i>"; break; } $dp_remote_object = spotEntity('object', $dp_remote_object_id); amplifyCell($dp_remote_object); $dp_neighbor['port'] = shortenIfName($dp_neighbor['port'], NULL, $dp_remote_object['id']); // get list of ports that have name matching CDP portname $remote_ports = array(); // list of remote (by DP info) ports foreach ($dp_remote_object['ports'] as $port) { if ($port['name'] == $dp_neighbor['port']) { $portinfo_remote = $port; $remote_ports[] = $port; } } // check if ports with such names exist on devices if (empty($local_ports)) { $error_message = "No such local port <i>{$local_port}</i>"; break; } if (empty($remote_ports)) { $error_message = "No such port on " . formatPortLink($dp_remote_object['id'], $dp_remote_object['name'], NULL, NULL); break; } // determine match or mismatch of local link foreach ($local_ports as $portinfo_local) { if ($portinfo_local['remote_id']) { if ($portinfo_local['remote_object_id'] == $dp_remote_object_id and $portinfo_local['remote_name'] == $dp_neighbor['port']) { // set $portinfo_remote to corresponding remote port foreach ($remote_ports as $portinfo_remote) { if ($portinfo_remote['id'] == $portinfo_local['remote_id']) { break; } } $link_matches = TRUE; unset($error_message); } elseif ($portinfo_local['remote_object_id'] != $dp_remote_object_id) { $error_message = "Remote device mismatch - port linked to " . formatLinkedPort($portinfo_local); } else { // ($portinfo_local['remote_name'] != $dp_neighbor['port']) $error_message = "Remote port mismatch - port linked to " . formatPortLink($portinfo_local['remote_object_id'], NULL, $portinfo_local['remote_id'], $portinfo_local['remote_name']); } break 2; } } // no local links found, try to search for remote links foreach ($remote_ports as $portinfo_remote) { if ($portinfo_remote['remote_id']) { $remote_link_html = formatLinkedPort($portinfo_remote); $remote_port_html = formatPortLink($portinfo_remote['object_id'], NULL, $portinfo_remote['id'], $portinfo_remote['name']); $error_message = "Remote port {$remote_port_html} is already linked to {$remote_link_html}"; break 2; } } // no links found on both sides, search for a compatible port pair $port_types = array(); foreach (array('left' => $local_ports, 'right' => $remote_ports) as $side => $port_list) { foreach ($port_list as $portinfo) { $tmp_types = $portinfo['iif_id'] == 1 ? array($portinfo['oif_id'] => $portinfo['oif_name']) : getExistingPortTypeOptions($portinfo['id']); foreach ($tmp_types as $oif_id => $oif_name) { $port_types[$side][$oif_id][] = array('id' => $oif_id, 'name' => $oif_name, 'portinfo' => $portinfo); } } } foreach ($port_types['left'] as $left_id => $left) { foreach ($port_types['right'] as $right_id => $right) { if (arePortTypesCompatible($left_id, $right_id)) { foreach ($left as $left_port) { foreach ($right as $right_port) { $variants[] = array('left' => $left_port, 'right' => $right_port); } } } } } if (!count($variants)) { // no compatible ports found $error_message = "Incompatible port types"; } } while (FALSE); // do { $tr_class = $link_matches ? 'trok' : (isset($error_message) ? 'trerror' : 'trwarning'); echo "<tr class=\"{$tr_class}\">"; if ($initial_row) { $count = count($remote_list); $td_class = ''; if (isset($hl_port_id) and $hl_port_id == $portinfo_local['id']) { $td_class = "class='border_highlight'"; } echo "<td rowspan=\"{$count}\" {$td_class} NOWRAP>" . ($portinfo_local ? formatPortLink($mydevice['id'], NULL, $portinfo_local['id'], $portinfo_local['name'], 'interactive-portname port-menu') : "<a class='interactive-portname port-menu nolink'>{$local_port}</a>") . ($count > 1 ? "<br> ({$count} neighbors)" : '') . '</td>'; $initial_row = FALSE; } echo "<td>" . ($portinfo_local ? formatPortIIFOIF($portinfo_local) : ' ') . "</td>"; echo "<td>" . formatIfTypeVariants($variants, "ports_{$inputno}") . "</td>"; echo "<td>{$dp_neighbor['device']}</td>"; echo "<td>" . ($portinfo_remote ? formatPortLink($dp_remote_object_id, NULL, $portinfo_remote['id'], $portinfo_remote['name']) : $dp_neighbor['port']) . "</td>"; echo "<td>" . ($portinfo_remote ? formatPortIIFOIF($portinfo_remote) : ' ') . "</td>"; echo "<td>"; if (!empty($variants)) { echo "<input type=checkbox name=do_{$inputno} class='cb-makelink'>"; $inputno++; } echo "</td>"; if (isset($error_message)) { echo "<td style=\"background-color: white; border-top: none\">{$error_message}</td>"; } echo "</tr>"; } } if ($inputno) { echo "<input type=hidden name=nports value={$inputno}>"; echo '<tr><td colspan=7 align=center>' . getImageHREF('CREATE', 'import selected', TRUE) . '</td></tr>'; } echo '</table></form>'; addJS(<<<END \$(document).ready(function () { \t\$('#cb-toggle').click(function (event) { \t\tvar list = \$('.cb-makelink'); \t\tfor (var i in list) { \t\t\tvar cb = list[i]; \t\t\tcb.checked = event.target.checked; \t\t} \t}).triggerHandler('click'); }); END , TRUE); }
function handleNetworkStickerClear() { global $sic, $pageno; assertUIntArg('attr_id'); if (permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $sic['attr_id'])))) { commitUpdateAttrForNetwork(spotEntity($pageno === 'ipv4net' ? 'ipv4net' : 'ipv6net', getBypassValue()), $sic['attr_id']); showSuccess("Attribute value cleared successfully"); } else { $oldvalues = getAttrValues(getBypassValue()); showError('Permission denied, "' . $oldvalues[$sic['attr_id']]['name'] . '" left unchanged'); } }
function renderPopupPortSelector() { if (isset($_REQUEST['do_link'])) { return handlePopupPortLink(); } assertPermission('depot', 'default'); assertUIntArg('port'); $port_id = $_REQUEST['port']; $port_info = getPortInfo($port_id); $in_rack = isCheckSet('in_rack'); // fill port filter structure $filter = array('racks' => array(), 'objects' => '', 'ports' => '', 'asset_no' => ''); if (isset($_REQUEST['filter-obj'])) { $filter['objects'] = trim($_REQUEST['filter-obj']); } if (isset($_REQUEST['filter-port'])) { $filter['ports'] = trim($_REQUEST['filter-port']); } if (isset($_REQUEST['filter-asset_no'])) { $filter['asset_no'] = trim($_REQUEST['filter-asset_no']); } if ($in_rack) { $object = spotEntity('object', $port_info['object_id']); if ($object['rack_id']) { // the object itself is mounted in a rack $filter['racks'] = getProximateRacks($object['rack_id'], getConfigVar('PROXIMITY_RANGE')); } elseif ($object['container_id']) { $container = spotEntity('object', $object['container_id']); if ($container['rack_id']) { $filter['racks'] = getProximateRacks($container['rack_id'], getConfigVar('PROXIMITY_RANGE')); } } } $spare_ports = array(); if (!empty($filter['racks']) || !empty($filter['objects']) || !empty($filter['ports']) || !empty($filter['asset_no'])) { $spare_ports = findSparePorts($port_info, $filter); } // display search form echo 'Link ' . formatPort($port_info) . ' to...'; echo '<form method=GET>'; startPortlet('Port list filter'); echo '<input type=hidden name="module" value="popup">'; echo '<input type=hidden name="helper" value="portlist">'; echo '<input type=hidden name="port" value="' . $port_id . '">'; echo '<table align="center" valign="bottom"><tr>'; echo '<td class="tdleft"><label>Object name:<br><input type=text size=8 name="filter-obj" value="' . htmlspecialchars($filter['objects'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft"><label>Asset tag:<br><input type=text size=8 name="filter-asset_no" value="' . htmlspecialchars($filter['asset_no'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft"><label>Port name:<br><input type=text size=6 name="filter-port" value="' . htmlspecialchars($filter['ports'], ENT_QUOTES) . '"></label></td>'; echo '<td class="tdleft" valign="bottom"><label><input type=checkbox name="in_rack"' . ($in_rack ? ' checked' : '') . '>Nearest racks</label></td>'; echo '<td valign="bottom"><input type=submit value="show ports"></td>'; echo '</tr></table>'; finishPortlet(); // display results startPortlet('Compatible spare ports'); if (empty($spare_ports)) { echo '(nothing found)'; } else { echo getSelect($spare_ports, array('name' => 'remote_port', 'size' => getConfigVar('MAXSELSIZE')), NULL, FALSE); echo "<p>Cable ID: <input type=text id=cable name=cable>"; // suggest patch cables where it makes sense $heaps = getPatchCableHeapOptionsForOIF($port_info['oif_id']); if (count($heaps)) { // Use + instead of array_merge() to avoid renumbering the keys. echo '<p>Patch cable: ' . getSelect(array(0 => 'none') + $heaps, array('name' => 'heap_id')); } echo "<p><input type='submit' value='Link' name='do_link'>"; } finishPortlet(); echo '</form>'; }
function trigger_ports() { assertUIntArg('object_id'); // Hide the tab if the object type exists in the exclusion config option if (considerConfiguredConstraint(spotEntity('object', $_REQUEST['object_id']), 'PORT_EXCLUSION_LISTSRC')) { return ''; } return 'std'; }
function importFingData() { $net = spotEntity('ipv4net', getBypassValue()); assertUIntArg('addrcount'); $nbad = $ngood = 0; for ($i = 1; $i <= $_REQUEST['addrcount']; $i++) { $inputname = "import_{$i}"; if (!isCheckSet($inputname)) { continue; } $ip_bin = assertIPv4Arg("addr_{$i}"); assertStringArg("descr_{$i}", TRUE); assertStringArg("rsvd_{$i}"); // Non-existent addresses will not have this argument set in request. $rsvd = 'no'; if ($_REQUEST["rsvd_{$i}"] == 'yes') { $rsvd = 'yes'; } try { if (!ip_in_range($ip_bin, $net)) { throw new InvalidArgException('ip_bin', $ip_bin); } updateAddress($ip_bin, $_REQUEST["descr_{$i}"], $rsvd); $ngood++; } catch (RackTablesError $e) { $nbad++; } } if (!$nbad) { showFuncMessage(__FUNCTION__, 'OK', array($ngood)); } else { showFuncMessage(__FUNCTION__, 'ERR', array($nbad, $ngood)); } }
function localtrigger_DellWarranty() { assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); $record = getAttrValues($object['id'], TRUE); if ($object['objtype_id'] == 4 && strstr($record[2][value], "Dell")) { return 1; } else { return ''; } }
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 ConfigTabHandler() { $dateadd = date("Y-m-d H:i:s"); // Add show/hide JS functionality for existing configuration fields echo "<SCRIPT language=\"JavaScript\">\n\t<!--\n\tfunction toggle_visibility(id){\n\tvar e = document.getElementById(id);\n\tif(e.style.display == 'block')\n\t\te.style.display = 'none';\n\telse\n\t\te.style.display = 'block';\n\t}\n\t//-->\n\t</script>\n"; // Print markup content for config tab $display = "<center>\n"; if (isset($_POST['op'])) { if ($_POST['op'] == "addConfig") { commitNewConfig($_POST['object_id'], $_POST['config'], $_POST['comments'], $_POST['dateadd']); } if ($_POST['op'] == "editConfig") { commitUpdateConfig($_POST['conf_id'], $_POST['config'], $_POST['comments'], $_POST['dateadd']); } } if (isset($_GET['op'])) { if ($_GET['op'] == "delConfig") { commitDeleteConfig($_GET['conf_id']); } } // Table header $display .= "<table cellspacing=0 cellpadding='5' align='center' class='widetable'>"; $display .= "<tr><th> </th>"; $display .= "<th class=tdleft></br>Saved Configurations</th>"; //$display .= "<th class=tdleft>Comment</th>"; $display .= "<th> </th></tr>"; assertUIntArg('object_id', __FUNCTION__); $object = spotEntity('object', $_REQUEST['object_id']); // Existing configs $query = "SELECT * FROM ObjectConfigs WHERE object_id = '{$object['id']}'"; $result = NULL; $result = usePreparedSelectBlade($query); while ($row = $result->fetch(PDO::FETCH_ASSOC)) { $conf_id = $row['id']; $object_id = $row['object_id']; $config = $row['config']; $comments = $row['comments']; $date = $row['date']; $display .= "<form method=post id=editConfig name=editConfig autocomplete=off action=\"\">"; $display .= "<input type=hidden name=\"conf_id\" value=\"" . $conf_id . "\">"; $display .= "<input type=hidden name=\"date\" value=\"" . $date . "\">"; $display .= "<input type=hidden name=\"op\" value=\"editConfig\">"; $display .= "<input type=hidden name=\"object_id\" value=\"" . $object_id . "\">"; $display .= "<tr><td><a href='?page=object&tab=configs&object_id=" . $object_id . "&op=delConfig&conf_id=" . $conf_id . "'onclick=\"javascript:return confirm('Are you sure you want to delete this Config?')\">"; $display .= "<img src='?module=chrome&uri=pix/tango-list-remove.png' width=16 height=16 border=0 title='Delete this Config'></a></td>"; $display .= "<td><a href=# onclick=toggle_visibility('{$conf_id}');>{$date}           Comments:  {$comments}</a>"; $display .= "</br><div id={$conf_id} style=display:none;><textarea style=background-color:#CCCCCC form=editConfig name=\"config\" cols=125 rows=15>" . $config . "</textarea></div></td><td></td>"; //$display .= "<td class='tdleft' NOWRAP><textarea name=comment value='".$comments."' cols=25 maxlength=254></textarea></td>"; $display .= "<td><input type=image name=submit class=icon src='?module=chrome&uri=pix/tango-document-save-16x16.png' border=0 title='Save' onclick=\"javascript:return confirm('Are you sure you want to overwrite this Config?')\"></td></form></tr>"; } // New config $display .= "<form action=\"\" method=post autocomplete=off id=\"addConfig\" name=\"addConfig\">"; $display .= "<input type=hidden name=\"object_id\" value=\"" . $object['id'] . "\">"; $display .= "<input type=hidden name=\"dateadd\" value=\"" . $dateadd . "\">"; $display .= "<input type=hidden name=\"op\" value=\"addConfig\">"; $display .= "<tr><td><input type=image name=submit class=icon src='?module=chrome&uri=pix/tango-list-add.png' border=0 title='Add a Config'></td>"; $display .= "<td class='tdleft'></br></br><p style=font-weight:bold;> Add New Configurations</p>Comment: <input cols=40 name=comments tabindex=102></br><textarea cols=125 rows=20 name=config tabindex=100 required></textarea></br></td></tr>"; $display .= "</form></br></table></br></center>"; // Output all .display strings to markup echo $display; }
function updateCableIdAJAX() { global $sic; assertUIntArg('id'); assertStringArg('text', TRUE); $port_info = getPortInfo($sic['id']); fixContext(spotEntity('object', $port_info['object_id'])); assertPermission('object', 'ports', 'editPort'); if (!$port_info['linked']) { throw new RackTablesError('Cant update cable ID: port is not linked'); } if ($port_info['reservation_comment'] !== $sic['text']) { commitUpdatePortLink($sic['id'], $sic['text']); } echo 'OK'; }
function fixContext($target = NULL) { global $pageno, $auto_tags, $expl_tags, $impl_tags, $target_given_tags, $user_given_tags, $etype_by_pageno, $page; if ($target !== NULL) { $target_given_tags = $target['etags']; // Don't reset autochain, because auth procedures could push stuff there in. // Another important point is to ignore 'user' realm, so we don't infuse effective // context with autotags of the displayed account. if ($target['realm'] != 'user') { $auto_tags = array_merge($auto_tags, $target['atags']); } } elseif (array_key_exists($pageno, $etype_by_pageno)) { // Each page listed in the map above requires one uint argument. $target_realm = $etype_by_pageno[$pageno]; assertUIntArg($page[$pageno]['bypass']); $target_id = $_REQUEST[$page[$pageno]['bypass']]; $target = spotEntity($target_realm, $target_id); $target_given_tags = $target['etags']; if ($target['realm'] != 'user') { $auto_tags = array_merge($auto_tags, $target['atags']); } } // Explicit and implicit chains should be normally empty at this point, so // overwrite the contents anyway. $expl_tags = mergeTagChains($user_given_tags, $target_given_tags); $impl_tags = getImplicitTags($expl_tags); }