• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP getAttrValues函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中getAttrValues函数的典型用法代码示例。如果您正苦于以下问题:PHP getAttrValues函数的具体用法?PHP getAttrValues怎么用?PHP getAttrValues使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了getAttrValues函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: getExpirationsText

function getExpirationsText()
{
    $row_format = "%3s|%-30s|%-15s|%-15s|%s\r\n";
    $ret = '';
    $breakdown = array();
    $breakdown[21] = array(array('from' => -365, 'to' => 0, 'title' => 'has expired within last year'), array('from' => 0, 'to' => 30, 'title' => 'expires within 30 days'));
    $breakdown[22] = $breakdown[21];
    $breakdown[24] = $breakdown[21];
    $attrmap = getAttrMap();
    foreach ($breakdown as $attr_id => $sections) {
        $ret .= $attrmap[$attr_id]['name'] . "\r\n";
        $ret .= "===========================================\r\n";
        foreach ($sections as $section) {
            $count = 1;
            $result = scanAttrRelativeDays($attr_id, $section['from'], $section['to']);
            if (!count($result)) {
                continue;
            }
            $ret .= $section['title'] . "\r\n";
            $ret .= "-----------------------------------------------------------------------------------\r\n";
            $ret .= sprintf($row_format, '#', 'Name', 'Asset Tag', 'OEM S/N 1', 'Date Warranty Expires');
            $ret .= "-----------------------------------------------------------------------------------\r\n";
            foreach ($result as $row) {
                $object = spotEntity('object', $row['object_id']);
                $attributes = getAttrValues($object['id']);
                $ret .= sprintf($row_format, $count, $object['dname'], $object['asset_no'], array_key_exists(1, $attributes) ? $attributes[1]['a_value'] : '', datetimestrFromTimestamp($row['uint_value']));
                $count++;
            }
            $ret .= "-----------------------------------------------------------------------------------\r\n";
        }
        $ret .= "\r\n";
    }
    return $ret;
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:34,代码来源:mail_expirations.php


示例2: requireMandatoryAttrGeneric

function requireMandatoryAttrGeneric($listsrc, $attr_id, $newval)
{
    $object_id = getBypassValue();
    $attrs = getAttrValues($object_id);
    if (array_key_exists($attr_id, $attrs) && considerGivenConstraint(spotEntity('object', $object_id), $listsrc) && !mb_strlen($newval)) {
        showError('Mandatory attribute "' . $attrs[$attr_id]['name'] . '" not set');
        stopOpPropagation();
    }
    return '';
}
开发者ID:dot-Sean,项目名称:racktables-contribs,代码行数:10,代码来源:mandatory_attr.php


示例3: checkTypeAndAttribute

function checkTypeAndAttribute($object_id, $type_id, $attr_id, $values, $hit = 'std')
{
    $object = spotEntity('object', $object_id);
    if ($object['objtype_id'] != $type_id) {
        return '';
    }
    foreach (getAttrValues($object_id) as $record) {
        if ($record['id'] == $attr_id and in_array($record['key'], $values)) {
            return $hit;
        }
    }
    return '';
}
开发者ID:rhysm,项目名称:racktables,代码行数:13,代码来源:triggers.php


示例4: detectDeviceBreed

function detectDeviceBreed($object_id)
{
    global $breed_by_swcode, $breed_by_hwcode, $breed_by_mgmtcode;
    foreach (getAttrValues($object_id) as $record) {
        if ($record['id'] == 4 and array_key_exists($record['key'], $breed_by_swcode)) {
            return $breed_by_swcode[$record['key']];
        } elseif ($record['id'] == 2 and array_key_exists($record['key'], $breed_by_hwcode)) {
            return $breed_by_hwcode[$record['key']];
        } elseif ($record['id'] == 30 and array_key_exists($record['key'], $breed_by_mgmtcode)) {
            return $breed_by_mgmtcode[$record['key']];
        }
    }
    return '';
}
开发者ID:ehironymous,项目名称:racktables,代码行数:14,代码来源:remote.php


示例5: getCellFilter

 //    UI handler: renderDepot()
 case 'get_depot':
     require_once 'inc/init.php';
     $cellfilter = getCellFilter();
     $objects = filterCellList(listCells('object'), $cellfilter['expression']);
     // get details if requested
     if (isset($_REQUEST['include_attrs'])) {
         foreach ($objects as $object_id => $object) {
             amplifyCell($object);
             // return the attributes in an array keyed on 'name', unless otherwise requested
             $key_attrs_on = 'name';
             if (isset($_REQUEST['key_attrs_on'])) {
                 $key_attrs_on = $_REQUEST['key_attrs_on'];
             }
             $attrs = array();
             foreach (getAttrValues($object_id) as $record) {
                 // check that the key exists for this record
                 if (!isset($record[$key_attrs_on])) {
                     throw new InvalidRequestArgException('key_attrs_on', $_REQUEST['key_attrs_on'], 'requested keying value not set for all attributes');
                 }
                 if (strlen($record['value'])) {
                     $attrs[$record[$key_attrs_on]] = $record;
                 }
             }
             $objects[$object_id] = $object;
             $objects[$object_id]['attrs'] = $attrs;
         }
     }
     sendAPIResponse($objects);
     break;
     // get all available object attributes
开发者ID:xtha,项目名称:salt,代码行数:31,代码来源:api.php


示例6: detectDeviceBreed

function detectDeviceBreed($object_id)
{
    $breed_by_swcode = array(251 => 'ios12', 252 => 'ios12', 254 => 'ios12', 963 => 'nxos4', 964 => 'nxos4', 1365 => 'nxos4', 1410 => 'nxos4', 1411 => 'nxos4', 1643 => 'nxos4', 1352 => 'xos12', 1360 => 'vrp53', 1361 => 'vrp55', 1369 => 'vrp55', 1363 => 'fdry5', 1367 => 'jun10', 1597 => 'jun10', 1598 => 'jun10', 1599 => 'jun10', 1594 => 'ftos8', 1673 => 'air12', 1674 => 'air12', 1675 => 'eos4', 1759 => 'iosxr4', 1786 => 'ros11', 242 => 'linux', 243 => 'linux', 1331 => 'linux', 1332 => 'linux', 1333 => 'linux', 1334 => 'linux', 1395 => 'linux', 1396 => 'linux');
    for ($i = 225; $i <= 235; $i++) {
        $breed_by_swcode[$i] = 'linux';
    }
    for ($i = 418; $i <= 436; $i++) {
        $breed_by_swcode[$i] = 'linux';
    }
    for ($i = 1417; $i <= 1422; $i++) {
        $breed_by_swcode[$i] = 'linux';
    }
    $breed_by_hwcode = array();
    for ($i = 589; $i <= 637; $i++) {
        $breed_by_hwcode[$i] = 'dlink';
    }
    $breed_by_mgmtcode = array(1788 => 'ucs');
    foreach (getAttrValues($object_id) as $record) {
        if ($record['id'] == 4 and array_key_exists($record['key'], $breed_by_swcode)) {
            return $breed_by_swcode[$record['key']];
        } elseif ($record['id'] == 2 and array_key_exists($record['key'], $breed_by_hwcode)) {
            return $breed_by_hwcode[$record['key']];
        } elseif ($record['id'] == 30 and array_key_exists($record['key'], $breed_by_mgmtcode)) {
            return $breed_by_mgmtcode[$record['key']];
        }
    }
    return '';
}
开发者ID:rhysm,项目名称:racktables,代码行数:28,代码来源:gateways.php


示例7: renderVMReport

function renderVMReport()
{
    $aResult = array();
    $iTotal = 0;
    $sFilter = '{$typeid_1504}';
    # typeid_1504 = Virtual machines
    foreach (scanRealmByText('object', $sFilter) as $Result) {
        $aResult[$Result['id']] = array();
        $aResult[$Result['id']]['sName'] = $Result['name'];
        // Create active links in comment
        $aResult[$Result['id']]['sComment'] = makeLinksInText($Result['comment']);
        // Load additional attributes:
        $attributes = getAttrValues($Result['id']);
        $aResult[$Result['id']]['sContact'] = '';
        if (isset($attributes['14']['a_value'])) {
            $aResult[$Result['id']]['sContact'] = $attributes['14']['a_value'];
        }
        $aResult[$Result['id']]['OEMSN'] = '';
        if (isset($attributes['1']['a_value'])) {
            $aResult[$Result['id']]['OEMSN'] = $attributes['1']['a_value'];
        }
        $aResult[$Result['id']]['sOS'] = '';
        if (isset($attributes['4']['a_value'])) {
            $aResult[$Result['id']]['sOS'] = $attributes['4']['a_value'];
        }
        // IP Informations
        $aResult[$Result['id']]['ipV4List'] = getObjectIPv4AllocationList($Result['id']);
        $aResult[$Result['id']]['ipV6List'] = getObjectIPv6AllocationList($Result['id']);
        // Port (MAC) Informations
        $aResult[$Result['id']]['ports'] = getObjectPortsAndLinks($Result['id']);
        // Container
        $aResult[$Result['id']]['container'] = getObjectContainerList($Result['id']);
        $iTotal++;
    }
    if (isset($_GET['csv'])) {
        header('Content-type: text/csv');
        header('Content-Disposition: attachment; filename=export_' . date("Ymdhis") . '.csv');
        header('Pragma: no-cache');
        header('Expires: 0');
        $outstream = fopen("php://output", "w");
        $aCSVRow = array('Name', 'MAC', 'IP(s)', 'Comment', 'Contact', 'OS', 'Hypervisor');
        fputcsv($outstream, $aCSVRow);
        foreach ($aResult as $id => $aRow) {
            $aCSVRow = array();
            $aCSVRow[0] = $aRow['sName'];
            $aCSVRow[1] = '';
            foreach ($aRow['ports'] as $portNumber => $aPortDetails) {
                if (trim($aPortDetails['l2address']) != '') {
                    $aCSVRow[1] .= $aPortDetails['l2address'] . ' ';
                }
            }
            $aCSVRow[1] = trim($aCSVRow[1]);
            $aCSVRow[2] = '';
            foreach ($aRow['ipV4List'] as $key => $aDetails) {
                if (function_exists('ip4_format')) {
                    $key = ip4_format($key);
                }
                if (trim($key) != '') {
                    $aCSVRow[2] .= $key . ' ';
                }
            }
            foreach ($aRow['ipV6List'] as $key => $aDetails) {
                if (function_exists('ip6_format')) {
                    $key = ip6_format($key);
                }
                if (trim($key) != '') {
                    $aCSVRow[2] .= $key . ' ';
                }
            }
            $aCSVRow[2] = trim($aCSVRow[2]);
            $aCSVRow[3] = str_replace('&quot;', "'", $aRow['sComment']);
            $aCSVRow[4] = $aRow['sContact'];
            $aCSVRow[5] = $aRow['sOS'];
            $aCSVRow[6] = '';
            foreach ($aRow['container'] as $key => $aDetails) {
                $aCSVRow[6] .= trim($aDetails['container_name']) . ' ';
            }
            $aCSVRow[6] = trim($aCSVRow[6]);
            fputcsv($outstream, $aCSVRow);
        }
        fclose($outstream);
        exit(0);
        # Exit normally after send CSV to browser
    }
    // Load stylesheet and jquery scripts
    addCSS('css/extensions/style.css');
    addJS('js/extensions/jquery-latest.js');
    addJS('js/extensions/jquery.tablesorter.js');
    addJS('js/extensions/picnet.table.filter.min.js');
    // Display the stat array
    echo "<h2>Virtual machines report ({$iTotal})</h2><ul>";
    echo '<a href="index.php?page=reports&tab=vm&csv">CSV Export</a>';
    echo '<table id="reportTable" class="tablesorter">
            <thead>
              <tr>
                <th>Name</th>
                <th>MAC</th>
                <th>IP(s)</th>
                <th>Comment</th>
                <th>Contact</th>
//.........这里部分代码省略.........
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:101,代码来源:vm-report.php


示例8: linkmgmt_renderObjectLinks

function linkmgmt_renderObjectLinks($object_id)
{
    $object = spotEntity('object', $object_id);
    $object['attr'] = getAttrValues($object_id);
    /* get ports */
    /* calls getObjectPortsAndLinks */
    amplifyCell($object);
    //$ports = getObjectPortsAndLinks($object_id);
    $ports = $object['ports'];
    /* reindex array so key starts at 0 */
    $ports = array_values($ports);
    /* URL param handling */
    if (isset($_GET['allports'])) {
        $allports = $_GET['allports'];
    } else {
        $allports = FALSE;
    }
    if (isset($_GET['allback'])) {
        $allback = $_GET['allback'];
    } else {
        $allback = FALSE;
    }
    echo '<table><tr>';
    if ($allports) {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allports', '0', '0')) . '">Hide Ports without link</a></td>';
    } else {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allports', '1', '0')) . '">Show All Ports</a></td>';
    }
    echo '<td width=200><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'PortLinkDialog', 'linktype' => 'back', 'byname' => '1'))) . '","name","height=700,width=800,scrollbars=yes");><a>Link Object Ports by Name</a></span></td>';
    if ($allback) {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allback', '0', '0')) . '">Collapse Backend Links on same Object</a></td>';
    } else {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allback', '1', '0')) . '">Expand Backend Links on same Object</a></td>';
    }
    /* Graphviz map */
    echo '<td width=100><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'map', 'usemap' => 1))) . '","name","height=800,width=800,scrollbars=yes");><a>Object Map</a></span></td>';
    /* Help */
    echo '<td width=200><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'Help'))) . '","name","height=400,width=500");><a>Help</a></span></td>';
    if (isset($_REQUEST['hl_port_id'])) {
        $hl_port_id = $_REQUEST['hl_port_id'];
    } else {
        $hl_port_id = NULL;
    }
    echo '</tr></table>';
    echo '<br><br><table id=renderobjectlinks0>';
    /*  switch display order depending on backend links */
    $first = portlist::hasbackend($object_id);
    $rowcount = 0;
    foreach ($ports as $key => $port) {
        $plist = new portlist($port, $object_id, $allports, $allback);
        //echo "<td><img src=\"index.php?module=redirect&page=object&tab=linkmgmt&op=map&object_id=$object_id&port_id=${port['id']}&allports=$allports\" ></td>";
        if ($plist->printportlistrow($first, $hl_port_id, $rowcount % 2 ? portlist::ALTERNATE_ROW_BGCOLOR : "#ffffff")) {
            $rowcount++;
        }
    }
    echo "</table>";
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:57,代码来源:linkmgmt.php


示例9: renderEditLocationForm

function renderEditLocationForm($location_id)
{
    global $pageno;
    $location = spotEntity('location', $location_id);
    amplifyCell($location);
    startPortlet('Attributes');
    printOpFormIntro('updateLocation');
    echo '<table border=0 align=center>';
    echo "<tr><td>&nbsp;</td><th class=tdright>Parent location:</th><td class=tdleft>";
    $locations = array();
    $locations[0] = '-- NOT SET --';
    foreach (listCells('location') as $id => $locationInfo) {
        $locations[$id] = $locationInfo['name'];
    }
    natcasesort($locations);
    printSelect($locations, array('name' => 'parent_id'), $location['parent_id']);
    echo "</td></tr>\n";
    echo "<tr><td>&nbsp;</td><th class=tdright>Name (required):</th><td class=tdleft><input type=text name=name value='{$location['name']}'></td></tr>\n";
    // optional attributes
    $values = getAttrValues($location_id);
    $num_attrs = count($values);
    echo "<input type=hidden name=num_attrs value={$num_attrs}>\n";
    $i = 0;
    foreach ($values as $record) {
        echo "<input type=hidden name={$i}_attr_id value={$record['id']}>";
        echo '<tr><td>';
        if (strlen($record['value'])) {
            echo "<a href='" . makeHrefProcess(array('op' => 'clearSticker', 'location_id' => $location_id, 'attr_id' => $record['id'])) . "'>";
            printImageHREF('clear', 'Clear value');
            echo '</a>';
        } else {
            echo '&nbsp;';
        }
        echo '</td>';
        echo "<th class=sticker>{$record['name']}:</th><td class=tdleft>";
        switch ($record['type']) {
            case 'uint':
            case 'float':
            case 'string':
                echo "<input type=text name={$i}_value value='{$record['value']}'>";
                break;
            case 'dict':
                $chapter = readChapter($record['chapter_id'], 'o');
                $chapter[0] = '-- NOT SET --';
                $chapter = cookOptgroups($chapter, 1562, $record['key']);
                printNiftySelect($chapter, array('name' => "{$i}_value"), $record['key']);
                break;
        }
        echo "</td></tr>\n";
        $i++;
    }
    echo "<tr><td>&nbsp;</td><th class=tdright>Has problems:</th><td class=tdleft><input type=checkbox name=has_problems";
    if ($location['has_problems'] == 'yes') {
        echo ' checked';
    }
    echo "></td></tr>\n";
    if (count($location['locations']) == 0 and count($location['rows']) == 0) {
        echo "<tr><td>&nbsp;</td><th class=tdright>Actions:</th><td class=tdleft>";
        echo "<a href='" . makeHrefProcess(array('op' => 'deleteLocation', 'location_id' => $location_id)) . "' onclick=\"javascript:return confirm('Are you sure you want to delete the location?')\">" . getImageHREF('destroy', 'Delete location') . "</a>";
        echo "&nbsp;</td></tr>\n";
    }
    echo "<tr><td colspan=3><b>Comment:</b><br><textarea name=comment rows=10 cols=80>{$location['comment']}</textarea></td></tr>";
    echo "<tr><td class=submit colspan=3>";
    printImageHREF('SAVE', 'Save changes', TRUE);
    echo "</td></tr>\n";
    echo '</form></table><br>';
    finishPortlet();
    startPortlet('History');
    renderObjectHistory($location_id);
    finishPortlet();
}
开发者ID:rhysm,项目名称:racktables,代码行数:71,代码来源:interface.php


示例10: renderPortletWattConsumption

function renderPortletWattConsumption($info)
{
    $rackTotalWattage = 0;
    $rackData = spotEntity('rack', $info['id']);
    amplifyCell($rackData);
    $objectChildren = getEntityRelatives('children', 'object', $objectData['id']);
    foreach ($rackData['mountedObjects'] as $object) {
        $objectData = spotEntity('object', $object);
        amplifyCell($objectData);
        foreach (getAttrValues($objectData['id']) as $record) {
            if ($record['name'] == 'Wattage consumption') {
                $rackTotalWattage += $record['value'];
            }
        }
    }
    startPortlet('Wattage Consumption');
    echo "<table border=0 cellspacing=5 align='center'><tr>";
    echo "<td>The total for attribute Wattage consuption is:  <b>{$rackTotalWattage}</b></td>\n";
    echo "</tr></table>\n";
    finishPortlet();
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:21,代码来源:wattage_consumption.php


示例11: snmpgeneric_opcreate

function snmpgeneric_opcreate()
{
    $object_id = $_REQUEST['object_id'];
    $attr = getAttrValues($object_id);
    //	sg_var_dump_html($_REQUEST);
    //	sg_var_dump_html($attr);
    /* commitUpdateAttrValue ($object_id, $attr_id, $new_value); */
    if (isset($_POST['updateattr'])) {
        foreach ($_POST['updateattr'] as $attr_id => $value) {
            //	if(empty($attr[$attr_id]['value']))
            if (!empty($value)) {
                commitUpdateAttrValue($object_id, $attr_id, $value);
                showSuccess("Attribute " . $attr[$attr_id]['name'] . " set to {$value}");
            }
        }
        unset($attr_id);
        unset($value);
    }
    /* updateattr */
    /* create ports */
    if (isset($_POST['portcreate'])) {
        foreach ($_POST['portcreate'] as $if => $value) {
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            $ifPhysAddress = isset($_POST['ifPhysAddress'][$if]) ? trim($_POST['ifPhysAddress'][$if]) : '';
            $ifAlias = isset($_POST['ifAlias'][$if]) ? trim($_POST['ifAlias'][$if]) : '';
            $ifDescr = isset($_POST['ifDescr'][$if]) ? trim($_POST['ifDescr'][$if]) : '';
            //$visible_label = (empty($ifAlias) ? '' : $ifAlias.'; ').$ifDescr;
            $visible_label = $ifAlias;
            if (empty($ifName)) {
                showError('Port without ifName ' . $_POST['porttypeid'][$if] . ', ' . $visible_label . ', ' . $ifPhysAddress);
            } else {
                commitAddPort($object_id, $ifName, $_POST['porttypeid'][$if], $visible_label, $ifPhysAddress);
                showSuccess('Port created ' . $ifName . ', ' . $_POST['porttypeid'][$if] . ', ' . $visible_label . ', ' . $ifPhysAddress);
            }
        }
        unset($if);
        unset($value);
    }
    /* portcreate */
    /* net create */
    if (isset($_POST['netcreate'])) {
        foreach ($_POST['netcreate'] as $id => $addrtype) {
            $range = $_POST['netprefix'][$id];
            $name = $_POST['netname'][$id];
            $is_reserved = isset($_POST['netreserve'][$id]);
            if ($addrtype == 'ipv4' || $addrtype == 'ipv4z') {
                createIPv4Prefix($range, $name, $is_reserved);
            } else {
                createIPv6Prefix($range, $name, $is_reserved);
            }
            showSuccess("{$range} {$name} created");
        }
        unset($id);
        unset($addrtype);
    }
    /* netcreate */
    /* allocate ipv6 adresses */
    if (isset($_POST['ipv6addrcreate'])) {
        foreach ($_POST['ipv6addrcreate'] as $ipaddr => $if) {
            bindIPv6ToObject(ip6_parse($ipaddr), $object_id, $_POST['ifName'][$if], 1);
            /* connected */
            showSuccess("{$ipaddr} allocated");
        }
        unset($ipaddr);
        unset($if);
    }
    /* allocate ip adresses */
    if (isset($_POST['ipaddrcreate'])) {
        foreach ($_POST['ipaddrcreate'] as $ipaddr => $if) {
            bindIPToObject(ip_parse($ipaddr), $object_id, $_POST['ifName'][$if], 1);
            /* connected */
            showSuccess("{$ipaddr} allocated");
        }
        unset($ipaddr);
        unset($if);
    }
    /* ipaddrecreate */
    /* update label */
    if (isset($_POST['updatelabel'])) {
        foreach ($_POST['updatelabel'] as $if => $port_id) {
            $ifAlias = isset($_POST['ifAlias'][$if]) ? trim($_POST['ifAlias'][$if]) : '';
            sg_commitUpdatePortLabel($object_id, $port_id, $ifAlias);
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            showSuccess("label updated on {$ifName} to {$ifAlias}");
        }
        unset($if);
        unset($port_id);
    }
    /* updatemac */
    /* update mac addresses only */
    if (isset($_POST['updatemac'])) {
        foreach ($_POST['updatemac'] as $if => $port_id) {
            $ifPhysAddress = isset($_POST['ifPhysAddress'][$if]) ? trim($_POST['ifPhysAddress'][$if]) : '';
            sg_commitUpdatePortl2address($object_id, $port_id, $ifPhysAddress);
            $ifName = isset($_POST['ifName'][$if]) ? trim($_POST['ifName'][$if]) : '';
            showSuccess("l2address updated on {$ifName} to {$ifPhysAddress}");
        }
        unset($if);
        unset($port_id);
    }
//.........这里部分代码省略.........
开发者ID:dot-Sean,项目名称:racktables-contribs,代码行数:101,代码来源:snmpgeneric.php


示例12: renderExpirations

function renderExpirations()
{
    global $nextorder;
    $breakdown = array();
    $breakdown[21] = array(array('from' => -365, 'to' => 0, 'class' => 'has_problems_', 'title' => 'has expired within last year'), array('from' => 0, 'to' => 30, 'class' => 'row_', 'title' => 'expires within 30 days'), array('from' => 30, 'to' => 60, 'class' => 'row_', 'title' => 'expires within 60 days'), array('from' => 60, 'to' => 90, 'class' => 'row_', 'title' => 'expires within 90 days'));
    $breakdown[22] = $breakdown[21];
    $breakdown[24] = $breakdown[21];
    $attrmap = getAttrMap();
    foreach ($breakdown as $attr_id => $sections) {
        startPortlet($attrmap[$attr_id]['name']);
        foreach ($sections as $section) {
            $count = 1;
            $order = 'odd';
            $result = scanAttrRelativeDays($attr_id, $section['from'], $section['to']);
            echo '<table align=center width=60% border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
            echo "<caption>{$section['title']}</caption>\n";
            if (!count($result)) {
                echo "<tr><td colspan=4>(none)</td></tr></table><br>\n";
                continue;
            }
            echo '<tr valign=top><th align=center>Count</th><th align=center>Name</th>';
            echo "<th align=center>Asset Tag</th><th align=center>OEM S/N 1</th><th align=center>Date Warranty <br> Expires</th></tr>\n";
            foreach ($result as $row) {
                $date_value = datetimestrFromTimestamp($row['uint_value']);
                $object = spotEntity('object', $row['object_id']);
                $attributes = getAttrValues($object['id']);
                $oem_sn_1 = array_key_exists(1, $attributes) ? $attributes[1]['a_value'] : '&nbsp;';
                echo '<tr class=' . $section['class'] . $order . ' valign=top>';
                echo "<td>{$count}</td>";
                echo '<td>' . mkA($object['dname'], 'object', $object['id']) . '</td>';
                echo "<td>{$object['asset_no']}</td>";
                echo "<td>{$oem_sn_1}</td>";
                echo "<td>{$date_value}</td>";
                echo "</tr>\n";
                $order = $nextorder[$order];
                $count++;
            }
            echo "</table><br>\n";
        }
        finishPortlet();
    }
}
开发者ID:xtha,项目名称:salt,代码行数:42,代码来源:interface.php


示例13: setSwitchVLANs

function setSwitchVLANs($object_id = 0, $setcmd)
{
    global $remote_username;
    $objectInfo = spotEntity('object', $object_id);
    $endpoints = findAllEndpoints($object_id, $objectInfo['name']);
    if (count($endpoints) == 0) {
        throw new RTGatewayError('no management address set');
    }
    if (count($endpoints) > 1) {
        throw new RTGatewayError('cannot pick management address');
    }
    $hwtype = $swtype = 'unknown';
    foreach (getAttrValues($object_id) as $record) {
        if ($record['name'] == 'SW type' && strlen($record['o_value'])) {
            $swtype = strtr(execGMarker($record['o_value']), ' ', '+');
        }
        if ($record['name'] == 'HW type' && strlen($record['o_value'])) {
            $hwtype = strtr(execGMarker($record['o_value']), ' ', '+');
        }
    }
    $endpoint = str_replace(' ', '+', $endpoints[0]);
    $data = queryGateway('switchvlans', array("connect {$endpoint} {$hwtype} {$swtype} {$remote_username}", $setcmd));
    // Finally we can parse the response into message array.
    foreach (explode(';', substr($data[1], strlen('OK!'))) as $text) {
        $message = 'gw: ' . substr($text, 2);
        if (strpos($text, 'I!') === 0) {
            showSuccess($message);
        } elseif (strpos($text, 'W!') === 0) {
            showWarning($message);
        } elseif (strpos($text, 'E!') === 0) {
            showError($message);
        } else {
            // All improperly formatted messages must be treated as error conditions.
            showError('unexpected line from gw: ' . $text);
        }
    }
}
开发者ID:cengn-tao,项目名称:racktables-contribs,代码行数:37,代码来源:livevlans.php


示例14: doSNMPmining

function doSNMPmining($object_id, $snmpsetup)
{
    $objectInfo = spotEntity('object', $object_id);
    $objectInfo['attrs'] = getAttrValues($object_id);
    $endpoints = findAllEndpoints($object_id, $objectInfo['name']);
    if (count($endpoints) == 0) {
        return showFuncMessage(__FUNCTION__, 'ERR1');
    }
    // endpoint not found
    if (count($endpoints) > 1) {
        return showFuncMessage(__FUNCTION__, 'ERR2');
    }
    // can't pick an address
    switch ($objectInfo['objtype_id']) {
        case 7:
        case 8:
            $device = new RTSNMPDevice($endpoints[0], $snmpsetup);
            return doSwitchSNMPmining($objectInfo, $device);
        case 2:
            $device = new APCPowerSwitch($endpoints[0], $snmpsetup);
            return doPDUSNMPmining($objectInfo, $device);
    }
}
开发者ID:ehironymous,项目名称:racktables,代码行数:23,代码来源:snmp.php


示例15: handleNetworkStickerClear

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');
    }
}
开发者ID:epx998,项目名称:racktables-contribs,代码行数:12,代码来源:network-attrs.php


示例16: getObjectTypeChangeOptions

function getObjectTypeChangeOptions($object_id)
{
    $map = getAttrMap();
    $used = array();
    $ret = array();
    foreach (getAttrValues($object_id) as $attr) {
        if (!array_key_exists($attr['id'], $map)) {
            return array();
        }
        // inconsistent current data
        if ($attr['value'] != '') {
            $used[] = $attr;
        }
    }
    foreach (readChapter(CHAP_OBJTYPE, 'o') as $test_id => $text) {
        foreach ($used as $attr) {
            $app = $map[$attr['id']]['application'];
            if (NULL === ($appidx = scanArrayForItem($app, 'objtype_id', $test_id)) or $attr['type'] == 'dict' and $attr['chapter_id'] != $app[$appidx]['chapter_no']) {
                continue 2;
            }
            // next type ID
        }
        $ret[$test_id] = $text;
    }
    return $ret;
}
开发者ID:rhysm,项目名称:racktables,代码行数:26,代码来源:functions.php


示例17: linkmgmt_renderObjectLinks

function linkmgmt_renderObjectLinks($object_id)
{
    $object = spotEntity('object', $object_id);
    $object['attr'] = getAttrValues($object_id);
    /* get ports */
    /* calls getObjectPortsAndLinks */
    amplifyCell($object);
    //$ports = getObjectPortsAndLinks($object_id);
    $ports = $object['ports'];
    /* reindex array so key starts at 0 */
    $ports = array_values($ports);
    /* URL param handling */
    if (isset($_GET['allports'])) {
        $allports = $_GET['allports'];
    } else {
        $allports = FALSE;
    }
    if (isset($_GET['allback'])) {
        $allback = $_GET['allback'];
    } else {
        $allback = FALSE;
    }
    echo '<table><tr>';
    if ($allports) {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allports', '0', '0')) . '">Hide Ports without link</a></td>';
    } else {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allports', '1', '0')) . '">Show All Ports</a></td>';
    }
    echo '<td width=200><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'PortLinkDialog', 'linktype' => 'back', 'byname' => '1'))) . '","name","height=700,width=800,scrollbars=yes");><a>Link Object Ports by Name</a></span></td>';
    if ($allback) {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allback', '0', '0')) . '">Collapse Backend Links on same Object</a></td>';
    } else {
        echo '<td width=200><a href="' . makeHref(portlist::urlparams('allback', '1', '0')) . '">Expand Backend Links on same Object</a></td>';
    }
    /* Graphviz map */
    echo '<td width=100><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'map', 'usemap' => 1))) . '","name","height=800,width=800,scrollbars=yes");><a>Object Map</a></span></td>';
    /* cytoscape map */
    echo '<td width=100><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'cytoscapemap'))) . '","name","height=800,width=800,scrollbars=yes");><a>Cytoscape Object Map</a></span></td>';
    /* Help */
    echo '<td width=200><span onclick=window.open("' . makeHrefProcess(portlist::urlparamsarray(array('op' => 'Help'))) . '","name","height=400,width=500");><a>Help</a></span></td>';
    if (isset($_REQUEST['hl_port_id'])) {
        $hl_port_id = $_REQUEST['hl_port_id'];
    } else {
        $hl_port_id = NULL;
    }
    echo '</tr></table>';
    echo '<br><br><table id=renderobjectlinks0>';
    /*  switch display order depending on backend links */
    $first = portlist::hasbackend($object_id);
    $rowcount = 0;
    foreach ($ports as $key => $port) {
        $lc = new lm_linkchain($port['id']);
        if ($allports || $lc->linkcount > 0) {
            if ($port['id'] == $hl_port_id) {
                $rowbgcolor = lm_linkchain::HL_PORT_BGCOLOR;
            } else {
                $rowbgcolor = $rowcount % 2 ? lm_linkchain::ALTERNATE_ROW_BGCOLOR : "#ffffff";
            }
            echo $lc->getchainlabeltrstart($rowbgcolor) . $lc->getchainrow($allback, $rowbgcolor) . "</tr>";
            $rowcount++;
        }
    }
    echo "</table>";
}
开发者ID:dot-Sean,项目名称:racktables-contribs,代码行数:64,代码来源:linkmgmt.php


示例18: copyLotOfObjects


//.........这里部分代码省略.........
            $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);
}
开发者ID:epx998,项目名称:racktables-contribs,代码行数:101,代码来

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP getAttribute函数代码示例发布时间:2022-05-15
下一篇:
PHP getAttachmentUrl函数代码示例发布时间:2022-05-15
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap