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


PHP safename函数代码示例

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


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

示例1: setUsername

  function setUsername($username)
	{
	  $userObj = object('user');
	  
	  $userObj->isNewUser = $this->ds['u_entity'] == 0;
	  $userObj->server = new HubbubServer(cfg('service/server'), true);
		$userObj->loadEntity();
		
		$userObj->entityDS['user'] = safename($username);
		$userObj->entityDS['url'] = getDefault($userObj->entityDS['url'], cfg('service/server').'/'.(cfg('service/url_rewrite') ? '' : '?').$username);
		$userObj->entityDS['_local'] = 'Y';
		$userObj->entityDS['_serverkey'] = $userObj->server->ds['s_key'];
		$userObj->entityDS['server'] = cfg('service/server');
		
		if(trim($userObj->entityDS['user']) != '') $ekey = DB_UpdateDataset('entities', $userObj->entityDS);
		$userObj->ds['u_entity'] = $ekey;
		
		if(trim($userObj->ds['u_name']) != '') DB_UpdateDataset('users', $userObj->ds);
    if($userObj->isNewUser) h2_execute_event('user_new', $userObj->entityDS, $userObj->ds);
	}
开发者ID:hcopr,项目名称:Hubbub,代码行数:20,代码来源:profile.model.php

示例2: get_device_icon

/**
 * Returns icon tag (by default) or icon name for current device array
 *
 * @param array $device Array with device info (from DB)
 * @param bool $base_icon Return complete img tag with icon (by default) or just base icon name
 *
 * @return string Img tag with icon or base icon name
 */
function get_device_icon($device, $base_icon = FALSE)
{
    global $config;
    $icon = 'generic';
    $device['os'] = strtolower($device['os']);
    if ($device['icon'] && is_file($config['html_dir'] . '/images/os/' . $device['icon'] . '.png')) {
        // Custom device icon from DB
        $icon = $device['icon'];
    } else {
        if ($config['os'][$device['os']]['icon'] && is_file($config['html_dir'] . '/images/os/' . $config['os'][$device['os']]['icon'] . '.png')) {
            // Icon defined in os definition
            $icon = $config['os'][$device['os']]['icon'];
        } else {
            if ($device['distro']) {
                // Icon by distro name
                $distro = safename(strtolower(trim($device['distro'])));
                if (is_file($config['html_dir'] . '/images/os/' . $distro . '.png')) {
                    $icon = $distro;
                }
            }
            if ($icon == 'generic' && is_file($config['html_dir'] . '/images/os/' . $device['os'] . '.png')) {
                // Icon by OS name
                $icon = $device['os'];
            }
        }
    }
    if ($icon == 'generic' && $config['os'][$device['os']]['vendor']) {
        // Icon by vendor name
        $vendor = safename(strtolower(trim($config['os'][$device['os']]['vendor'])));
        if (is_file($config['html_dir'] . '/images/os/' . $vendor . '.png')) {
            $icon = $vendor;
        }
    }
    if ($base_icon) {
        return $icon;
    } else {
        // Image tag
        $image = '<img src="' . $config['base_url'] . '/images/os/' . $icon . '.png" alt="" />';
        return $image;
    }
}
开发者ID:rhizalpatrax64bit,项目名称:StacksNetwork,代码行数:49,代码来源:device.inc.php

示例3: get_rrd_path

function get_rrd_path($device, $filename)
{
    global $config;
    $filename = safename(trim($filename));
    // If filename empty, return base rrd dirname for device (for example in delete_device())
    $rrd_file = trim($config['rrd_dir']) . '/';
    if (strlen($device['hostname'])) {
        $rrd_file .= $device['hostname'] . '/';
    }
    if (strlen($filename) > 0) {
        $ext = pathinfo($filename, PATHINFO_EXTENSION);
        if ($ext != 'rrd') {
            $filename .= '.rrd';
        }
        // Add rrd extension if not already set
        $rrd_file .= safename($filename);
        // Add rrd filename to global array $graph_return
        $GLOBALS['graph_return']['rrds'][] = $rrd_file;
    }
    return $rrd_file;
}
开发者ID:Natolumin,项目名称:observium,代码行数:21,代码来源:rrdtool.inc.php

示例4: foreach

<?php

foreach (dbFetchRows("SELECT * FROM mempools WHERE device_id = ?", array($device['device_id'])) as $mempool) {
    echo "Mempool " . $mempool['mempool_descr'] . ": ";
    $mempool_rrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("mempool-" . $mempool['mempool_type'] . "-" . $mempool['mempool_index'] . ".rrd");
    $file = $config['install_dir'] . "/includes/polling/mempools/" . $mempool['mempool_type'] . ".inc.php";
    if (is_file($file)) {
        include $file;
    } else {
        // Do we need a generic mempool poller?
    }
    if ($mempool['total']) {
        $percent = round($mempool['used'] / $mempool['total'] * 100, 2);
    } else {
        $percent = 0;
    }
    echo $percent . "% ";
    if (!is_file($mempool_rrd)) {
        rrdtool_create($mempool_rrd, "--step 300 DS:used:GAUGE:600:0:U DS:free:GAUGE:600:0:U " . $config['rrd_rra']);
    }
    rrdtool_update($mempool_rrd, "N:" . $mempool['used'] . ":" . $mempool['free']);
    $mempool['state'] = array('mempool_used' => $mempool['used'], 'mempool_perc' => $percent, 'mempool_free' => $mempool['free'], 'mempool_total' => $mempool['total'], 'mempool_largestfree' => $mempool['largestfree'], 'mempool_lowestfree' => $mempool['lowestfree']);
    if ($config['memcached']['enable']) {
        if ($debug) {
            print_r($mempool['state']);
        }
        $memcache->set('mempool-' . $mempool['mempool_id'] . '-value', $mempool['state']);
    } else {
        dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id']));
    }
    echo "\n";
开发者ID:CumulusNetworks,项目名称:cldemo-archive,代码行数:31,代码来源:mempools.inc.php

示例5: snmp_get

}
if (empty($hardware)) {
    $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB');
}
$oids_AP_Name = array('bsnAPName');
$oids_AP_Users = array('bsnApIfNoOfUsers');
foreach ($oids_AP_Name as $oid) {
    $stats = snmpwalk_cache_oid($device, $oid, $stats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
}
foreach ($oids_AP_Users as $oid) {
    $APstats = snmpwalk_cache_oid($device, $oid, $APstats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb');
}
$numAccessPoints = count($stats);
$numClients = 0;
foreach ($APstats as $key => $value) {
    $numClients += $value['bsnApIfNoOfUsers'];
}
$rrdfile = $host_rrd . '/ciscowlc' . safename('.rrd');
if (!is_file($rrdfile)) {
    rrdtool_create($rrdfile, ' --step 300 DS:NUMAPS:GAUGE:600:0:12500000000 DS:NUMCLIENTS:GAUGE:600:0:12500000000 ' . $config['rrd_rra']);
}
$fields = array('NUMAPS' => $numAccessPoints, 'NUMCLIENTS' => $numClients);
$ret = rrdtool_update($rrdfile, $fields);
// also save the info about how many clients in the same place as the wireless module
$wificlientsrrd = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('wificlients-radio1.rrd');
if (!is_file($wificlientsrrd)) {
    rrdtool_create($wificlientsrrd, '--step 300 DS:wificlients:GAUGE:600:-273:10000 ' . $config['rrd_rra']);
}
$fields = array('wificlients' => $numClients);
rrdtool_update($wificlientsrrd, $fields);
$graphs['wifi_clients'] = true;
开发者ID:sfromm,项目名称:librenms,代码行数:31,代码来源:ciscowlc.inc.php

示例6: safename

<?php

$rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cbgp-' . $data['bgpPeerIdentifier'] . '.ipv6.vpn.rrd');
require 'includes/graphs/bgp/prefixes.inc.php';
开发者ID:samyscoub,项目名称:librenms,代码行数:4,代码来源:prefixes_ipv6vpn.inc.php

示例7: get_sensor_rrd

function get_sensor_rrd($device, $sensor)
{
    global $config;
    # For IPMI, sensors tend to change order, and there is no index, so we prefer to use the description as key here.
    if ($config['os'][$device['os']]['sensor_descr'] || $sensor['poller_type'] == "ipmi") {
        $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sensor-" . $sensor['sensor_class'] . "-" . $sensor['sensor_type'] . "-" . $sensor['sensor_descr'] . ".rrd");
    } else {
        $rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("sensor-" . $sensor['sensor_class'] . "-" . $sensor['sensor_type'] . "-" . $sensor['sensor_index'] . ".rrd");
    }
    return $rrd_file;
}
开发者ID:zphj1987,项目名称:librenms,代码行数:11,代码来源:common.php

示例8: substr

 $interference = $aruba_apstats["1.3.6.1.4.1.14823.2.2.1.5.3.1.6.1.11.{$radioid}"][''] + 0;
 $radionum = substr($radioid, strlen($radioid) - 1, 1);
 if ($debug) {
     echo "* radioid: {$radioid}\n";
     echo "  radionum: {$radionum}\n";
     echo "  name: {$name}\n";
     echo "  type: {$type}\n";
     echo "  channel: {$channel}\n";
     echo "  txpow: {$txpow}\n";
     echo "  radioutil: {$radioutil}\n";
     echo "  numasoclients: {$numasoclients}\n";
     echo "  interference: {$interference}\n";
 }
 // if there is a numeric channel, assume the rest of the data is valid, I guess
 if (is_numeric($channel)) {
     $rrd_file = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename("arubaap-{$name}.{$radionum}.rrd");
     if (!is_file($rrd_file)) {
         $dslist = 'DS:channel:GAUGE:600:0:200 ';
         $dslist .= 'DS:txpow:GAUGE:600:0:200 ';
         $dslist .= 'DS:radioutil:GAUGE:600:0:100 ';
         $dslist .= 'DS:nummonclients:GAUGE:600:0:500 ';
         $dslist .= 'DS:nummonbssid:GAUGE:600:0:200 ';
         $dslist .= 'DS:numasoclients:GAUGE:600:0:500 ';
         $dslist .= 'DS:interference:GAUGE:600:0:2000 ';
         rrdtool_create($rrd_file, "--step 300 {$dslist} " . $config['rrd_rra']);
     }
     $fields = array('channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, 'nummonclients' => $nummonclients, 'nummonbssid' => $nummonbssid, 'numasoclients' => $numasoclients, 'interference' => $interference);
     rrdtool_update($rrd_file, $fields);
 }
 // generate the mac address
 $macparts = explode('.', $radioid, -1);
开发者ID:samyscoub,项目名称:librenms,代码行数:31,代码来源:aruba-controller.inc.php

示例9: safename

<?php

$rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . "-adsl.rrd");
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = "Downstream";
$rrd_list[0]['ds'] = "AturChanCurrTxRate";
$rrd_list[1]['filename'] = $rrd_filename;
$rrd_list[1]['descr'] = "Upstream";
$rrd_list[1]['ds'] = "AtucChanCurrTxRate";
$unit_text = "Bits/sec";
$units = '';
$total_units = '';
$colours = 'mixed';
$scale_min = "0";
$nototal = 1;
if ($rrd_list) {
    include "includes/graphs/generic_multi_line.inc.php";
}
开发者ID:REAP720801,项目名称:librenms,代码行数:18,代码来源:adsl_speed.inc.php

示例10: foreach

<?php

$i = 1;
foreach (dbFetchRows('SELECT * FROM `ucd_diskio` AS U, `devices` AS D WHERE D.device_id = ? AND U.device_id = D.device_id', array($device['device_id'])) as $disk) {
    $rrd_filename = $config['rrd_dir'] . '/' . $disk['hostname'] . '/ucd_diskio-' . safename($disk['diskio_descr'] . '.rrd');
    if (is_file($rrd_filename)) {
        $rrd_list[$i]['filename'] = $rrd_filename;
        $rrd_list[$i]['descr'] = $disk['diskio_descr'];
        $rrd_list[$i]['ds_in'] = $ds_in;
        $rrd_list[$i]['ds_out'] = $ds_out;
        $i++;
    }
}
开发者ID:sfromm,项目名称:librenms,代码行数:13,代码来源:diskio_common.inc.php

示例11: safename

<?php

require 'includes/graphs/common.inc.php';
$rrd_filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('ib_dns_performance.rrd');
$rrd_options .= " --vertical-label='Answer time in milliseconds'";
$rrd_options .= " --lower-limit='0'";
$stats = array('PerfAA' => '#74C366FF', 'PerfnonAA' => '#007283FF');
$i = 0;
foreach ($stats as $stat => $color) {
    $i++;
    $rrd_list[$i]['filename'] = $rrd_filename;
    $rrd_list[$i]['descr'] = ucfirst($stat);
    $rrd_list[$i]['ds'] = $stat;
    # Set up DEFs
    $rrd_options .= " DEF:" . $stat . "=" . $rrd_filename . ':' . $stat . ':AVERAGE ';
    # Set up area graphing with stacking
    if ($i == "0") {
        $rrd_options .= " 'AREA:" . $stat . $color . ":" . $stat . "'";
    } else {
        $rrd_options .= " 'AREA:" . $stat . $color . ":" . $stat . ":STACK'";
    }
    # Set up legend, with consistent indent
    $filler = 15 - strlen($stat);
    $current_pad = str_pad("", $filler, ' ', STR_PAD_LEFT);
    $rrd_options .= " 'GPRINT:" . $stat . ":LAST: " . $current_pad . "Current\\:%8.0lf'";
    $rrd_options .= " 'GPRINT:" . $stat . ":AVERAGE:Average\\:%8.0lf'";
    $rrd_options .= " 'GPRINT:" . $stat . ":MAX:Maximum\\:%8.0lf\\n'";
}
# Add total value
$rrd_options .= " 'CDEF:cdeftotal=PerfAA,PerfnonAA,+'";
$rrd_options .= " 'LINE1:cdeftotal#000000FF:Total'";
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:ib_dns_performance.inc.php

示例12: array

<?php

$cpe_oids = array('cpeExtPsePortEnable', 'cpeExtPsePortDiscoverMode', 'cpeExtPsePortDeviceDetected', 'cpeExtPsePortIeeePd', 'cpeExtPsePortAdditionalStatus', 'cpeExtPsePortPwrMax', 'cpeExtPsePortPwrAllocated', 'cpeExtPsePortPwrAvailable', 'cpeExtPsePortPwrConsumption', 'cpeExtPsePortMaxPwrDrawn', 'cpeExtPsePortEntPhyIndex', 'cpeExtPsePortEntPhyIndex', 'cpeExtPsePortPolicingCapable', 'cpeExtPsePortPolicingEnable', 'cpeExtPsePortPolicingAction', 'cpeExtPsePortPwrManAlloc');
$peth_oids = array('pethPsePortAdminEnable', 'pethPsePortPowerPairsControlAbility', 'pethPsePortPowerPairs', 'pethPsePortDetectionStatus', 'pethPsePortPowerPriority', 'pethPsePortMPSAbsentCounter', 'pethPsePortType', 'pethPsePortPowerClassifications', 'pethPsePortInvalidSignatureCounter', 'pethPsePortPowerDeniedCounter', 'pethPsePortOverLoadCounter', 'pethPsePortShortCounter', 'pethMainPseConsumptionPower');
$port_stats = snmpwalk_cache_oid($device, 'pethPsePortEntry', $port_stats, 'POWER-ETHERNET-MIB');
$port_stats = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', $port_stats, 'CISCO-POWER-ETHERNET-EXT-MIB');
if ($port_stats[$port['ifIndex']] && $port['ifType'] == 'ethernetCsmacd' && isset($port_stats[$port['ifIndex']]['dot3StatsIndex'])) {
    // Check to make sure Port data is cached.
    $this_port =& $port_stats[$port['ifIndex']];
    $rrdfile = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('port-' . $port['ifIndex'] . '-poe.rrd');
    if (!file_exists($rrdfile)) {
        $rrd_create .= $config['rrd_rra'];
        // FIXME CISCOSPECIFIC
        $rrd_create .= ' DS:PortPwrAllocated:GAUGE:600:0:U';
        $rrd_create .= ' DS:PortPwrAvailable:GAUGE:600:0:U';
        $rrd_create .= ' DS:PortConsumption:DERIVE:600:0:U';
        $rrd_create .= ' DS:PortMaxPwrDrawn:GAUGE:600:0:U ';
        rrdtool_create($rrdfile, $rrd_create);
    }
    $upd = "{$polled}:" . $port['cpeExtPsePortPwrAllocated'] . ':' . $port['cpeExtPsePortPwrAvailable'] . ':' . $port['cpeExtPsePortPwrConsumption'] . ':' . $port['cpeExtPsePortMaxPwrDrawn'];
    $ret = rrdtool_update("{$rrdfile}", $upd);
    echo 'PoE ';
}
//end if
开发者ID:rasssta,项目名称:librenms,代码行数:24,代码来源:port-poe.inc.php

示例13: foreach

 foreach ($cefs as $entity => $afis) {
     $entity_name = $entity_array[$entity]['entPhysicalName'] . ' - ' . $entity_array[$entity]['entPhysicalModelName'];
     echo "\n{$entity} {$entity_name}\n";
     foreach ($afis as $afi => $paths) {
         echo " |- {$afi}\n";
         foreach ($paths as $path => $cef_stat) {
             echo ' | |-' . $path . ': ' . $cef_stat['cefSwitchingPath'];
             $cef_id = $device['device_id'] . '-' . $entity . '-' . $afi . '-' . $path;
             // if (dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1")
             if (!isset($cefs_db[$cef_id])) {
                 dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $path, 'cef_path' => $cef_stat['cefSwitchingPath']), 'cef_switching');
                 echo '+';
             }
             unset($cefs_db[$cef_id]);
             $cef_entry = dbFetchRow('SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $path));
             $filename = $config['rrd_dir'] . '/' . $device['hostname'] . '/' . safename('cefswitching-' . $entity . '-' . $afi . '-' . $path . '.rrd');
             if (!is_file($filename)) {
                 rrdtool_create($filename, '--step 300 
                     DS:drop:DERIVE:600:0:1000000 
                     DS:punt:DERIVE:600:0:1000000 
                     DS:hostpunt:DERIVE:600:0:1000000 ' . $config['rrd_rra']);
             }
             // Copy HC to non-HC if they exist
             if (is_numeric($cef_stat['cefSwitchingHCDrop'])) {
                 $cef_stat['cefSwitchingDrop'] = $cef_stat['cefSwitchingHCDrop'];
             }
             if (is_numeric($cef_stat['cefSwitchingHCPunt'])) {
                 $cef_stat['cefSwitchingPunt'] = $cef_stat['cefSwitchingHCPunt'];
             }
             if (is_numeric($cef_stat['cefSwitchingHCPunt2Host'])) {
                 $cef_stat['cefSwitchingPunt2Host'] = $cef_stat['cefSwitchingHCPunt2Host'];
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:cisco-cef.inc.php

示例14: foreach

 * Free Software Foundation, either version 3 of the License, or (at your
 * option) any later version.  Please see LICENSE.txt at the top level of
 * the source code distribution for details.
 */
if ($device['os_group'] == "cisco") {
    // TODO: Need to test partial PRI.
    // Total
    $total = 0;
    foreach (snmpwalk_cache_oid_num($device, "1.3.6.1.2.1.2.2.1.3", NULL) as $key => $value) {
        // 81 is the ifType for DS0's
        if ($value[''] == "81") {
            $total++;
        }
    }
    // Active
    $active = snmpwalk_cache_oid_num($device, "1.3.6.1.4.1.9.10.19.1.1.4.0", NULL);
    $active = $active['1.3.6.1.4.1.9.10.19.1.1.4.0'][''];
    if (isset($active) && $active != "" && $total != 0) {
        $rrd_filename = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("cisco-iospri.rrd");
        if (!file_exists($rrd_filename)) {
            rrdtool_create($rrd_filename, " DS:total:GAUGE:600:0:U DS:active:GAUGE:600:0:U" . $config['rrd_rra']);
        }
        $fields = array('total' => $total, 'active' => $active);
        rrdtool_update($rrd_filename, $fields);
        $tags = array();
        influx_update($device, 'cisco-iospri', $tags, $fields);
        $graphs['cisco-iospri'] = TRUE;
        echo " Cisco IOS PRI ";
    }
    unset($rrd_filename, $total, $active);
}
开发者ID:greggcz,项目名称:librenms,代码行数:31,代码来源:cisco-iospri.inc.php

示例15: mysql_fetch_array

<?php

$scale_min = "0";
include "common.inc.php";
$rrd_options .= " COMMENT:'                                 Last   Max\\n'";
$voltage = mysql_fetch_array(mysql_query("SELECT * FROM voltage where volt_id = '" . mres($_GET['id']) . "'"));
$hostname = mysql_result(mysql_query("SELECT hostname FROM devices WHERE device_id = '" . $voltage['device_id'] . "'"), 0);
$voltage['volt_descr_fixed'] = substr(str_pad($voltage['volt_descr'], 28), 0, 28);
$rrd_filename = $config['rrd_dir'] . "/" . $hostname . "/" . safename("volt-" . $voltage['volt_descr'] . ".rrd");
$rrd_options .= " DEF:volt={$rrd_filename}:volt:AVERAGE";
$rrd_options .= " AREA:volt#FFFF99";
$rrd_options .= " LINE1.5:volt#cc0000:'" . $voltage['volt_descr_fixed'] . "'";
$rrd_options .= " GPRINT:volt:LAST:%3.0lfV";
$rrd_options .= " GPRINT:volt:MAX:%3.0lfV\\\\l";
开发者ID:kyrisu,项目名称:observernms,代码行数:14,代码来源:voltage.inc.php


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