本文整理汇总了PHP中assertUIntArg函数的典型用法代码示例。如果您正苦于以下问题:PHP assertUIntArg函数的具体用法?PHP assertUIntArg怎么用?PHP assertUIntArg使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了assertUIntArg函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: NagiosTabHandler
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>';
}
示例2: localtrigger_Link2Nagios
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 '';
}
}
示例3: ripeTab
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";
}
示例4: getChapterList
$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
示例5: localtrigger_PortLinker
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 '';
}
}
示例6: localexecute_PortGenerator
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})");
}
}
示例7: doVSMigrate
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');
}
示例8: getTripletConfigAJAX
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>';
}
示例9: updateVLANDomain
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");
}
示例10: linkmgmt_renderPopupPortSelector
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">';
//.........这里部分代码省略.........
示例11: cloneRSPool
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));
}
示例12: copyLotOfObjects
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) {
//.........这里部分代码省略.........
示例13: renderPopupPortSelector
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>';
}
示例14: updateNodePingCheck
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'])));
}
示例15: renderDiscoveredNeighbors
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
//.........这里部分代码省略.........