当前位置: 首页>>代码示例>>PHP>>正文


PHP ifclass函数代码示例

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


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

示例1: generate_port_popup

function generate_port_popup($port, $text = NULL, $type = NULL)
{
    global $config;
    if (!isset($port['os'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    humanize_port($port);
    if (!$text) {
        $text = rewrite_ifname($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['os'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = generate_device_popup_header($port);
    $content .= generate_port_popup_header($port);
    $content .= '<div style="width: 700px">';
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = "yes";
    $graph_array['height'] = "100";
    $graph_array['width'] = "275";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_id'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['week'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['month'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['year'];
    $content .= generate_graph_tag($graph_array);
    $content .= "</div>";
    return $content;
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:40,代码来源:port.inc.php

示例2: generate_port_link

function generate_port_link($port, $text = null, $type = null, $overlib = 1, $single_graph = 0)
{
    global $config;
    $graph_array = array();
    $port = ifNameDescr($port);
    if (!$text) {
        $text = fixIfName($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['hostname'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = '<div class=list-large>' . $port['hostname'] . ' - ' . fixifName($port['label']) . '</div>';
    if ($port['ifAlias']) {
        $content .= escape_quotes($port['ifAlias']) . '<br />';
    }
    $content .= "<div style=\\'width: 850px\\'>";
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = 'yes';
    $graph_array['height'] = '100';
    $graph_array['width'] = '340';
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_id'];
    $content .= generate_graph_tag($graph_array);
    if ($single_graph == 0) {
        $graph_array['from'] = $config['time']['week'];
        $content .= generate_graph_tag($graph_array);
        $graph_array['from'] = $config['time']['month'];
        $content .= generate_graph_tag($graph_array);
        $graph_array['from'] = $config['time']['year'];
        $content .= generate_graph_tag($graph_array);
    }
    $content .= '</div>';
    $url = generate_port_url($port);
    if ($overlib == 0) {
        return $content;
    } else {
        if (port_permitted($port['port_id'], $port['device_id'])) {
            return overlib_link($url, $text, $content, $class);
        } else {
            return fixifName($text);
        }
    }
}
开发者ID:RobsanInc,项目名称:librenms,代码行数:51,代码来源:functions.inc.php

示例3: humanize_port

/**
 * Humanize port.
 *
 * Returns a the $port array with processed information:
 * label, humans_speed, human_type, html_class and human_mac
 * row_class, table_tab_colour
 *
 * @param array $ports
 * @return array $ports
 *
 */
function humanize_port(&$port)
{
    global $config;
    // Process port data to make it pretty for printing. EVOLUTION, BITCHES.
    // Lots of hacky shit will end up here with if (os);
    $device = device_by_id_cache($port['device_id']);
    $os = $device['os'];
    $port['human_speed'] = humanspeed($port['ifSpeed']);
    $port['human_type'] = fixiftype($port['ifType']);
    $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    $port['human_mac'] = formatMac($port['ifPhysAddress']);
    if (isset($config['os'][$os]['ifname'])) {
        $port['label'] = $port['ifName'];
        if ($port['ifName'] == "") {
            $port['label'] = $port['ifDescr'];
        } else {
            $port['label'] = $port['ifName'];
        }
    } elseif (isset($config['os'][$os]['ifalias'])) {
        $port['label'] = $port['ifAlias'];
    } else {
        $port['label'] = $port['ifDescr'];
        if (isset($config['os'][$os]['ifindex'])) {
            $port['label'] = $port['label'] . " " . $port['ifIndex'];
        }
    }
    if ($device['os'] == "speedtouch") {
        list($port['label']) = explode("thomson", $port['label']);
    }
    if ($port['ifAdminStatus'] == "down") {
        $port['table_tab_colour'] = "#aaaaaa";
        $port['row_class'] = "";
    } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "down") {
        $port['table_tab_colour'] = "#cc0000";
        $port['row_class'] = "error";
    } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "lowerLayerDown") {
        $port['table_tab_colour'] = "#ff6600";
        $port['row_class'] = "warning";
    } elseif ($port['ifAdminStatus'] == "up" && $port['ifOperStatus'] == "up") {
        $port['table_tab_colour'] = "#194B7F";
        $port['row_class'] = "";
    }
    $port['humanized'] = TRUE;
    /// Set this so we can check it later.
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:56,代码来源:rewrites.php

示例4: foreach

        <th style="width: 250px;"><span style="font-weight: bold;" class="interface">Description</span></th>
        <th style="width: 150px;">Device</th>
        <th style="width: 100px;">Interface</th>
        <th style="width: 100px;">Speed</th>
        <th style="width: 100px;">Circuit</th>
        <th>Notes</th>
      </tr>
  </thead>

<?php 
    foreach ($ports as $port) {
        $done = "yes";
        unset($class);
        $port['ifAlias'] = str_ireplace($type . ": ", "", $port['ifAlias']);
        $port['ifAlias'] = str_ireplace("[PNI]", "Private", $port['ifAlias']);
        $ifclass = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
        if ($bg == "#ffffff") {
            $bg = "#e5e5e5";
        } else {
            $bg = "#ffffff";
        }
        echo "<tr class='iftype'>\n             <td><span class=entity-title>" . generate_port_link($port, $port['port_descr_descr']) . "</span>";
        #            <span class=small style='float: left;'>".generate_device_link($port)." ".generate_port_link($port)." </span>");
        if (dbFetchCell("SELECT count(*) FROM mac_accounting WHERE port_id = ?", array($port['port_id']))) {
            echo "<span style='float: right;'><a href='device/device=" . $port['device_id'] . "/tab=port/port=" . $port['port_id'] . "/view=macaccounting/'><img src='images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
        }
        echo "</td>";
        echo '   <td style="width: 150px;" class="strong">' . generate_device_link($port) . '</td>
             <td style="width: 150px;" class="strong">' . generate_port_link($port, short_ifname($port['ifDescr'])) . '</td>
             <td style="width: 75px;">' . $port['port_descr_speed'] . '</td>
             <td style="width: 150px;">' . $port['port_descr_circuit'] . '</td>
开发者ID:skive,项目名称:observium,代码行数:31,代码来源:iftype.inc.php

示例5: testIfclass

 /**
  * @dataProvider providerIfclass
  */
 public function testIfclass($ifOperStatus, $ifAdminStatus, $result)
 {
     $this->assertSame($result, ifclass($ifOperStatus, $ifAdminStatus));
 }
开发者ID:skive,项目名称:observium,代码行数:7,代码来源:IncludesCommonTest.php

示例6: generateiflink

function generateiflink($interface, $text = 0, $type = NULL)
{
    global $twoday;
    global $now;
    global $config;
    global $day;
    global $month;
    $interface = ifNameDescr($interface);
    if (!$text) {
        $text = fixIfName($interface['label']);
    }
    if (isset($type)) {
        $interface['graph_type'] = $type;
    } else {
        $interface['graph_type'] = 'port_bits';
    }
    if (!isset($interface['hostname'])) {
        $interface = array_merge($interface, device_by_id_cache($interface['device_id']));
    }
    $class = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
    $graph_url = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;from={$day}&amp;to={$now}&amp;width=400&amp;height=100&amp;type=" . $interface['graph_type'];
    $graph_url_month = $config['base_url'] . "/graph.php?port=" . $interface['interface_id'] . "&amp;from={$month}&amp;to={$now}&amp;width=400&amp;height=100&amp;type=" . $interface['graph_type'];
    $device_id = getifhost($interface['interface_id']);
    $url = $config['base_url'] . "/device/{$device_id}/interface/" . $interface['interface_id'] . "/";
    $contents = "<div class=list-large>" . $interface['hostname'] . " - " . fixifName($interface['label']) . "</div>";
    if ($interface['ifAlias']) {
        $contents .= htmlentities($interface['ifAlias'] . "<br />");
    }
    $contents .= "<img src=\\'{$graph_url}\\'><br /><img src=\\'{$graph_url_month}\\'>";
    $link = overlib_link($url, $text, $contents, $class);
    return $link;
}
开发者ID:kyrisu,项目名称:observernms_clean,代码行数:32,代码来源:functions.php

示例7: generate_port_link

function generate_port_link($port, $text = NULL, $type = NULL)
{
    global $config;
    if (isset($port['humanized']) == FALSE) {
        humanize_port($port);
    }
    if (!$text) {
        $text = fixIfName($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['os'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = generate_device_link_header($port);
    $content .= generate_port_link_header($port);
    $content .= '<div style="width: 700px">';
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = "yes";
    $graph_array['height'] = "100";
    $graph_array['width'] = "275";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_id'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['week'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['month'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['year'];
    $content .= generate_graph_tag($graph_array);
    $content .= "</div>";
    $url = generate_port_url($port);
    if (port_permitted($port['port_id'], $port['device_id'])) {
        return overlib_link($url, $text, $content, $class);
    } else {
        return fixifName($text);
    }
}
开发者ID:RomanBogachev,项目名称:observium,代码行数:44,代码来源:functions.inc.php

示例8: implode

}
$types = implode(' + ', $types_array);
echo "<tr bgcolor='{$bg}'>\n             <td><span class=list-large>Total Graph for ports of type : " . $types . "</span></td></tr>";
echo "<tr bgcolor='{$bg}'><td>";
$graph_type = "multi_bits";
$interface['interface_id'] = $if_list;
include "includes/print-interface-graphs.inc.php";
echo "</td></tr>";
$sql = "select * from ports as I, devices as D WHERE {$type_where} AND I.device_id = D.device_id ORDER BY I.ifAlias";
$query = mysql_query($sql);
while ($interface = mysql_fetch_array($query)) {
    $done = "yes";
    unset($class);
    $interface['ifAlias'] = str_ireplace($type . ": ", "", $interface['ifAlias']);
    $interface['ifAlias'] = str_ireplace("[PNI]", "Private", $interface['ifAlias']);
    $ifclass = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']);
    if ($bg == "#ffffff") {
        $bg = "#e5e5e5";
    } else {
        $bg = "#ffffff";
    }
    echo "<tr bgcolor='{$bg}'>\n             <td><span class=list-large>" . generateiflink($interface, $interface['ifAlias']) . "</span><br /> \n            <span class=interface-desc style='float: left;'>" . generatedevicelink($interface) . " " . generateiflink($interface) . " </span>";
    if (mysql_result(mysql_query("SELECT count(*) FROM mac_accounting WHERE interface_id = '" . $interface['interface_id'] . "'"), 0)) {
        echo "<span style='float: right;'><a href='" . $config['base_url'] . "/device/" . $interface['device_id'] . "/interface/" . $interface['interface_id'] . "/macaccounting/'><img src='/images/16/chart_curve.png' align='absmiddle'> MAC Accounting</a></span>";
    }
    echo "</td></tr><tr bgcolor='{$bg}'><td>";
    if (file_exists($config['rrd_dir'] . "/" . $interface['hostname'] . "/" . $interface['ifIndex'] . ".rrd")) {
        $graph_type = "port_bits";
        include "includes/print-interface-graphs.inc.php";
    }
    echo "</td></tr>";
开发者ID:kyrisu,项目名称:observernms,代码行数:31,代码来源:iftype.php

示例9: generate_port_link

function generate_port_link($port, $text = NULL, $type = NULL)
{
    global $config;
    $port = ifNameDescr($port);
    if (!$text) {
        $text = fixIfName($port['label']);
    }
    if ($type) {
        $port['graph_type'] = $type;
    }
    if (!isset($port['graph_type'])) {
        $port['graph_type'] = 'port_bits';
    }
    $class = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    if (!isset($port['hostname'])) {
        $port = array_merge($port, device_by_id_cache($port['device_id']));
    }
    $content = "<div class=list-large>" . $port['hostname'] . " - " . fixifName($port['label']) . "</div>";
    if ($port['ifAlias']) {
        $content .= $port['ifAlias'] . "<br />";
    }
    $content .= "<div style=\\'width: 850px\\'>";
    $graph_array['type'] = $port['graph_type'];
    $graph_array['legend'] = "yes";
    $graph_array['height'] = "100";
    $graph_array['width'] = "340";
    $graph_array['to'] = $config['time']['now'];
    $graph_array['from'] = $config['time']['day'];
    $graph_array['id'] = $port['port_id'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['week'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['month'];
    $content .= generate_graph_tag($graph_array);
    $graph_array['from'] = $config['time']['year'];
    $content .= generate_graph_tag($graph_array);
    $content .= "</div>";
    $url = generate_port_url($port);
    if (port_permitted($port['port_id'], $port['device_id'])) {
        return overlib_link($url, $text, $content, $class);
    } else {
        return fixifName($text);
    }
}
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:44,代码来源:functions.inc.php

示例10: humanize_port

function humanize_port(&$port)
{
    global $config, $cache;
    // Exit if already humanized
    if ($port['humanized']) {
        return;
    }
    // Process port data to make it pretty for printing. EVOLUTION, BITCHES.
    // Lots of hacky shit will end up here with if (os);
    // If we can get the device data from the global cache, do it, else pull it from the db (mostly for external scripts)
    if (is_array($GLOBALS['cache']['devices']['id'][$port['device_id']])) {
        $device =& $GLOBALS['cache']['devices']['id'][$port['device_id']];
    } else {
        $device = device_by_id_cache($port['device_id']);
    }
    $os = $device['os'];
    $port['human_speed'] = humanspeed($port['ifSpeed']);
    $port['human_type'] = rewrite_iftype($port['ifType']);
    $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    $port['human_mac'] = format_mac($port['ifPhysAddress']);
    // Here definition override for ifDescr, because Calix switch ifDescr <> ifName since fw 2.2
    // Note, only for 'calix' os now
    if ($os == 'calix') {
        unset($config['os'][$os]['ifname']);
        $version_parts = explode('.', $device['version']);
        if ($version_parts[0] > 2 || $version_parts[0] == 2 && $version_parts[1] > 1) {
            $config['os'][$os]['ifname'] = 1;
        }
    }
    if (isset($config['os'][$os]['ifname'])) {
        if ($port['ifName'] == "") {
            $port['label'] = $port['ifDescr'];
        } else {
            $port['label'] = $port['ifName'];
        }
    } elseif (isset($config['os'][$os]['ifalias'])) {
        $port['label'] = $port['ifAlias'];
    } else {
        $port['label'] = $port['ifDescr'];
        if (isset($config['os'][$os]['ifindex'])) {
            $port['label'] .= ' ' . $port['ifIndex'];
        } else {
            $port['label'] = $port['ifDescr'];
        }
    }
    // Set entity variables for use by code which uses entities
    $port['entity_name'] = $port['label'];
    $port['entity_shortname'] = $port['label'];
    $port['entity_descr'] = $port['ifAlias'];
    if ($device['os'] == "speedtouch") {
        list($port['label']) = explode("thomson", $port['label']);
    }
    $port['table_tab_colour'] = "#aaaaaa";
    $port['row_class'] = "";
    // Default
    $port['admin_status'] = $port['ifAdminStatus'];
    if ($port['ifAdminStatus'] == "down") {
        $port['admin_status'] = 'disabled';
        $port['row_class'] = "warning";
        $port['icon'] = 'port-disabled';
    } elseif ($port['ifAdminStatus'] == "up") {
        $port['admin_status'] = 'enabled';
        switch ($port['ifOperStatus']) {
            case 'down':
                $port['table_tab_colour'] = "#cc0000";
                $port['row_class'] = "error";
                $port['icon'] = 'port-down';
                break;
            case 'monitoring':
                // This is monitoring ([e|r]span) ports
                $port['table_tab_colour'] = "#008C00";
                $port['row_class'] = "success";
                $port['icon'] = 'port-up';
                break;
            case 'lowerLayerDown':
                $port['table_tab_colour'] = "#ff6600";
                $port['row_class'] = "warning";
                $port['icon'] = 'port-down';
                break;
            case 'testing':
                $port['table_tab_colour'] = "#85004b";
                $port['row_class'] = "info";
                $port['icon'] = 'port-ignored';
                break;
            case 'up':
                $port['table_tab_colour'] = "#194B7F";
                $port['row_class'] = "";
                $port['icon'] = 'port-up';
                break;
        }
    }
    // If the device is down, colour the row/tab as 'warning' meaning that the entity is down because of something below it.
    if ($device['status'] == '0') {
        $port['table_tab_colour'] = "#ff6600";
        $port['row_class'] = "warning";
        $port['icon'] = 'port-ignored';
    }
    $port['in_rate'] = $port['ifInOctets_rate'] * 8;
    $port['out_rate'] = $port['ifOutOctets_rate'] * 8;
    // Colour in bps based on speed if > 50, else by UI convention.
//.........这里部分代码省略.........
开发者ID:skive,项目名称:observium,代码行数:101,代码来源:rewrites.inc.php

示例11: generate_port_link

function generate_port_link($port, $text = NULL, $type = NULL)
{
    global $config;
    humanize_port($port);
    if (!isset($port['html_class'])) {
        $port['html_class'] = ifclass($port['ifOperStatus'], $port['ifAdminStatus']);
    }
    if (!isset($text)) {
        $text = rewrite_ifname($port['label']);
    }
    #if (!isset($port['os'])) { $port = array_merge($port, device_by_id_cache($port['device_id'])); }
    $url = generate_port_url($port);
    if (port_permitted($port['port_id'], $port['device_id'])) {
        return '<a href="' . $url . '" class="entity-popup ' . $port['html_class'] . '" data-eid="' . $port['port_id'] . '" data-etype="port">' . $text . '</a>';
    } else {
        return rewrite_ifname($text);
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:18,代码来源:functions.inc.php


注:本文中的ifclass函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。