本文整理汇总了PHP中generate_device_url函数的典型用法代码示例。如果您正苦于以下问题:PHP generate_device_url函数的具体用法?PHP generate_device_url怎么用?PHP generate_device_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了generate_device_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: print_message
print_message("Adding host {$hostname} communit" . (count($config['snmp']['community']) == 1 ? 'y' : 'ies') . ' ' . implode(', ', $config['snmp']['community']) . " port {$port} using {$transport}");
} elseif ($_POST['snmpver'] === 'v3') {
$v3 = array('authlevel' => mres($_POST['authlevel']), 'authname' => mres($_POST['authname']), 'authpass' => mres($_POST['authpass']), 'authalgo' => mres($_POST['authalgo']), 'cryptopass' => mres($_POST['cryptopass']), 'cryptoalgo' => mres($_POST['cryptoalgo']));
array_push($config['snmp']['v3'], $v3);
$snmpver = 'v3';
print_message("Adding SNMPv3 host {$hostname} port {$port}");
} else {
print_error('Unsupported SNMP Version. There was a dropdown menu, how did you reach this error ?');
}
//end if
$poller_group = $_POST['poller_group'];
$force_add = $_POST['force_add'] == 'on';
$port_assoc_mode = $_POST['port_assoc_mode'];
try {
$device_id = addHost($hostname, $snmpver, $port, $transport, $poller_group, $force_add, $port_assoc_mode);
$link = generate_device_url(array('device_id' => $device_id));
print_message("Device added <a href='{$link}'>{$hostname} ({$device_id})</a>");
} catch (HostUnreachableException $e) {
print_error($e->getMessage());
foreach ($e->getReasons() as $reason) {
print_error($reason);
}
} catch (Exception $e) {
print_error($e->getMessage());
}
} else {
print_error("You don't have the necessary privileges to add hosts.");
}
//end if
echo ' </div>
<div class="col-sm-3">
示例2: generate_device_link
function generate_device_link($device, $text = NULL, $vars = array(), $escape = TRUE)
{
if (is_array($device) && !$device['hostname']) {
$device = device_by_id_cache($device['device_id']);
}
if (!device_permitted($device['device_id'])) {
$text = $escape ? escape_html($device['hostname']) : $device['hostname'];
return $text;
}
$class = devclass($device);
if (!$text) {
$text = $device['hostname'];
}
$url = generate_device_url($device, $vars);
//$link = overlib_link($url, $text, $contents, $class, $escape);
if ($escape) {
$text = escape_html($text);
}
return '<a href="' . $url . '" class="entity-popup ' . $class . '" data-eid="' . $device['device_id'] . '" data-etype="device">' . $text . '</a>';
}
示例3: generate_device_url
* 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.
*/
echo '<td>';
if (device_permitted($device['device_id'])) {
echo '<div class="row">
<div class="col-xs-1">';
echo '<a href="' . generate_device_url($device) . '"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device" /></a> ';
echo '</div>
<div class="col-xs-1">';
echo '<a href="' . generate_device_url($device, array('tab' => 'alerts')) . '"> <img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts" /></a> ';
echo '</div>';
if ($_SESSION['userlevel'] >= "7") {
echo '<div class="col-xs-1">
<a href="' . generate_device_url($device, array('tab' => 'edit')) . '"> <img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit device" title="Edit device" /></a>
</div>';
}
echo '</div>
<div class="row">
<div class="col-xs-1">
<a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"></a>
</div>
<div class="col-xs-1">
<a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"></a>
</div>
<div class="col-xs-1">
<a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"></a>
</div>
</div>';
}
示例4: dbFetchRows
<?php
/**
* Observium
*
* This file is part of Observium.
*
* @package observium
* @subpackage search
* @copyright (C) 2006-2013 Adam Armstrong, (C) 2013-2016 Observium Limited
*
*/
/// SEARCH DEVICES
$results = dbFetchRows("SELECT * FROM `devices`\n WHERE (`hostname` LIKE ? OR `location` LIKE ?) {$query_permitted_device}\n ORDER BY `hostname` LIMIT {$query_limit}", array($query_param, $query_param));
if (count($results)) {
foreach ($results as $result) {
humanize_device($result);
$name = $result['hostname'];
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
$device_search_results[] = array('url' => generate_device_url($result), 'name' => $name, 'colour' => $result['html_tab_colour'], 'icon' => get_device_icon($result), 'data' => array(escape_html($result['hardware'] . ' | ' . $config['os'][$result['os']]['text'] . ' ' . $result['version']), highlight_search(escape_html($result['location'])) . ' | ' . $num_ports . ' ports'));
}
$search_results['devices'] = array('descr' => 'Devices found', 'results' => $device_search_results);
}
// EOF
示例5: strtolower
$type = strtolower($device['os']);
$image = getImage($device);
if ($device['os'] == 'ios') {
formatCiscoHardware($device, true);
}
$device['os_text'] = $config['os'][$device['os']]['text'];
$port_count = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE `device_id` = ?', array($device['device_id']));
$sensor_count = dbFetchCell('SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ?', array($device['device_id']));
$actions = '
<div class="container-fluid">
<div class="row">
<div class="col-xs-1"><a href="' . generate_device_url($device) . '"> <img src="images/16/server.png" border="0" align="absmiddle" alt="View device" title="View device"></a></div>
<div class="col-xs-1"><a href="' . generate_device_url($device, array('tab' => 'alerts')) . '"> <img src="images/16/bell.png" border="0" align="absmiddle" alt="View alerts" title="View alerts"></a></div>
';
if ($_SESSION['userlevel'] >= '7') {
$actions .= '<div class="col-xs-1"><a href="' . generate_device_url($device, array('tab' => 'edit')) . '"> <img src="images/16/wrench.png" border="0" align="absmiddle" alt="Edit device" title="Edit device"></a></div>';
}
if ($subformat == 'detail') {
$actions .= '</div><div class="row">';
}
$actions .= '
<div class="col-xs-1"><a href="telnet://' . $device['hostname'] . '"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></div>
<div class="col-xs-1"><a href="ssh://' . $device['hostname'] . '"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"></a></div>
<div class="col-xs-1"><a href="https://' . $device['hostname'] . '"><img src="images/16/http.png" alt="https" title="Launch browser https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"></a></div>
</div>
</div>
';
$hostname = generate_device_link($device);
if (extension_loaded('mbstring')) {
$location = mb_substr($device['location'], 0, 32, 'utf8');
} else {
示例6: mres
include $config['html_dir'] . "/includes/cache-data.inc.php";
// Is there a POST/GET query string?
if (isset($_REQUEST['queryString'])) {
$queryString = mres($_REQUEST['queryString']);
// Is the string length greater than 0?
if (strlen($queryString) > 0) {
$found = 0;
/// SEARCH DEVICES
$query_permitted_device = generate_query_permitted(array('device'), array('device_table' => 'devices'));
$results = dbFetchRows("SELECT * FROM `devices`\n WHERE (`hostname` LIKE '%{$queryString}%' OR `location` LIKE '%{$queryString}%') {$query_permitted_device}\n ORDER BY `hostname` LIMIT 8");
if (count($results)) {
$found = 1;
echo '<li class="nav-header">Devices found: ' . count($results) . '</li>' . PHP_EOL;
foreach ($results as $result) {
echo '<li class="divider" style="margin: 0px;"></li>' . PHP_EOL;
echo '<li style="margin: 0px;">' . PHP_EOL . ' <a href="' . generate_device_url($result) . '">' . PHP_EOL;
humanize_device($result);
$name = $result['hostname'];
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
echo ' <dl style="border-left: 10px solid ' . $result['html_tab_colour'] . '; " class="dl-horizontal dl-search">
<dt style="padding-left: 10px; text-align: center;">' . getImage($result) . '</dt>
<dd>
<strong>' . highlight_search(htmlentities($name)) . '
<small>' . htmlentities($result['hardware']) . ' | ' . htmlentities($config['os'][$result['os']]['text']) . ' ' . htmlentities($result['version']) . '
<br /> ' . highlight_search(htmlentities($result['location'], 0, 'UTF-8')) . ' | ' . $num_ports . ' ports</small>
</strong>
</dd>
</dl>
示例7: sprintf
$map_init = "[" . $config['leaflet']['default_lat'] . ", " . $config['leaflet']['default_lng'] . "], " . sprintf("%01.0f", $config['leaflet']['default_zoom']);
$temp_output .= 'var map = L.map(\'leaflet-map\').setView(' . $map_init . ');
L.tileLayer(\'//{s}.tile.openstreetmap.org/{z}/{x}/{y}.png\', {
attribution: \'© <a href="http://osm.org/copyright">OpenStreetMap</a> contributors\'
}).addTo(map);
var markers = L.markerClusterGroup();
var redMarker = L.AwesomeMarkers.icon({
icon: \'server\',
markerColor: \'red\', prefix: \'fa\', iconColor: \'white\'
});
var greenMarker = L.AwesomeMarkers.icon({
icon: \'server\',
markerColor: \'green\', prefix: \'fa\', iconColor: \'white\'
});
';
foreach (dbFetchRows("SELECT `device_id`,`hostname`,`os`,`status`,`lat`,`lng` FROM `devices` LEFT JOIN `locations` ON `devices`.`location`=`locations`.`location` WHERE `disabled`=0 AND `ignore`=0 AND `lat` != '' AND `lng` != '' ORDER BY `status` ASC, `hostname`") as $map_devices) {
$icon = 'greenMarker';
if ($map_devices['status'] == 0) {
$icon = 'redMarker';
}
$temp_output .= "var title = '<a href=\"" . generate_device_url($map_devices) . "\"><img src=\"" . getImageSrc($map_devices) . "\" width=\"32\" height=\"32\" alt=\"\">" . $map_devices['hostname'] . "</a>';\n var marker = L.marker(new L.LatLng(" . $map_devices['lat'] . ", " . $map_devices['lng'] . "), {title: title, icon: {$icon}});\n marker.bindPopup(title);\n markers.addLayer(marker);\n";
}
$temp_output .= 'map.addLayer(markers);
</script>';
} else {
$temp_output = 'Mapael engine not supported here';
}
unset($common_output);
$common_output[] = $temp_output;
示例8: AND
if (isset($searchPhrase) && !empty($searchPhrase)) {
$sql .= " AND (hostname LIKE '%{$searchPhrase}%' OR last_polled LIKE '%{$searchPhrase}%' OR last_polled_timetaken LIKE '%{$searchPhrase}%')";
}
if ($_POST['type'] == "unpolled") {
$sql .= " AND `last_polled` <= DATE_ADD(NOW(), INTERVAL - 15 minute)";
}
if (!isset($sort) || empty($sort)) {
$sort = 'last_polled_timetaken DESC';
}
$sql .= " AND D.status ='1' AND D.ignore='0' AND D.disabled='0' ORDER BY {$sort}";
$count_sql = "SELECT COUNT(`D`.`device_id`) {$sql}";
$total = dbFetchCell($count_sql);
if (empty($total)) {
$total = 0;
}
if (isset($current)) {
$limit_low = $current * $rowCount - $rowCount;
$limit_high = $rowCount;
}
if ($rowCount != -1) {
$sql .= " LIMIT {$limit_low},{$limit_high}";
}
$sql = "SELECT D.device_id,D.hostname AS `hostname`, D.last_polled AS `last_polled`, `group_name`, D.last_polled_timetaken AS `last_polled_timetaken` {$sql}";
foreach (dbFetchRows($sql, array(), true) as $device) {
if (empty($device['group_name'])) {
$device['group_name'] = 'General';
}
$response[] = array('hostname' => "<a class='list-device' href='" . generate_device_url($device, array('tab' => 'graphs', 'group' => 'poller')) . "'>" . $device['hostname'] . '</a>', 'last_polled' => $device['last_polled'], 'poller_group' => $device['group_name'], 'last_polled_timetaken' => $device['last_polled_timetaken']);
}
$output = array('current' => $current, 'rowCount' => $rowCount, 'rows' => $response, 'total' => $total);
echo _json_encode($output);
示例9: generate_device_url
}
echo '<div class="dropdown pull-right">
<button class="btn btn-default dropdown-toggle" type="button" data-toggle="dropdown"><i class="fa fa-cog"></i>
<span class="caret"></span></button>
<ul class="dropdown-menu">
<li><a href="https://' . $device['hostname'] . '" target="_blank"><img src="images/16/http.png" alt="https" title="Launch browser to https://' . $device['hostname'] . '" border="0" width="16" height="16" target="_blank"> Web</a></li>
<li><a href="ssh://' . $device['hostname'] . '" target="_blank"><img src="images/16/ssh.png" alt="ssh" title="SSH to ' . $device['hostname'] . '" border="0" width="16" height="16"> SSH</a></li>
<li><a href="telnet://' . $device['hostname'] . '" target="_blank"><img src="images/16/telnet.png" alt="telnet" title="Telnet to ' . $device['hostname'] . '" border="0" width="16" height="16"> Telnet</a></li>';
if (is_admin()) {
echo '<li>
<a href="' . generate_device_url($device, array('tab' => 'edit')) . '">
<img src="images/16/wrench.png" align="absmiddle" border="0" />
Edit
</a>
</li>';
echo '<li><a href="' . generate_device_url($device, array('tab' => 'capture')) . '">
<img src="images/16/brick_error.png" align="absmiddle" border="0" /> Capture
</a></li>';
}
echo '</ul>
</div>';
echo '</ul>';
}
//end if
if (device_permitted($device['device_id']) || $check_device == $vars['device']) {
echo '<div class="tabcontent">';
require 'pages/device/' . mres(basename($tab)) . '.inc.php';
echo '</div>';
} else {
require 'includes/error-no-perm.inc.php';
}
示例10: mres
if (isset($_POST['queryString']) || isset($_GET['queryString'])) {
if (isset($_POST['queryString'])) {
$queryString = mres($_POST['queryString']);
} elseif (isset($_GET['queryString'])) {
$queryString = mres($_GET['queryString']);
}
// Is the string length greater than 0?
if (strlen($queryString) > 0) {
/// SEARCH DEVICES
$results = dbFetchRows("SELECT * FROM `devices` WHERE `hostname` LIKE '%" . $queryString . "%' OR `location` LIKE '%" . $queryString . "%' ORDER BY hostname LIMIT 8");
if (count($results)) {
echo '<li class="nav-header">Devices found: ' . count($results) . '</li>';
foreach ($results as $result) {
echo '<li class="divider" style="margin: 0px;"></li>';
echo "<li>";
echo '<a href="' . generate_device_url($result) . '">';
humanize_device($result);
$name = $result['hostname'];
if (strlen($name) > 35) {
$name = substr($name, 0, 35) . "...";
}
// $description = $result->desc;
// if (strlen($description) > 80) { $description = substr($description, 0, 80) . "..."; }
$num_ports = dbFetchCell("SELECT COUNT(*) FROM `ports` WHERE device_id = ?", array($result['device_id']));
echo '<dl style="border-left: 10px solid ' . $result['html_tab_colour'] . '; " class="dl-horizontal dl-search">
<dt style="padding-left: 10px; text-align: center;">' . $result['icon'] . '</dt>
<dd><h5>' . highlight_search($name) . '</h5>
<small>' . $result['hardware'] . ' | ' . $config['os'][$result['os']]['text'] . ' ' . $result['version'] . '
<br /> ' . highlight_search($result['location']) . ' | ' . $num_ports . 'ports</small></dd>
</dl>';
}
示例11: date
$xml->addChild('icon', $base_url . '/' . $GLOBALS['config']['favicon']);
$xml->addChild('link');
$xml->link->addAttribute('href', $feed_link);
$self_link = $xml->addChild('link', '', $atom_ns);
$self_link->addAttribute('href', $base_url . $_SERVER['REQUEST_URI']);
$self_link->addAttribute('rel', 'self');
$self_link->addAttribute('type', 'application/atom+xml');
$xml->addChild('generator', $feed_generator);
$xml->addChild('updated', date(DATE_ATOM, strtotime($events['updated'])));
}
foreach ($events['entries'] as $entry) {
$entry_device = device_by_id_cache($entry['device_id']);
$entry_vars = array('page' => 'device', 'device' => $entry['device_id'], 'tab' => 'logs', 'section' => 'eventlog', 'type' => $entry['type'], 'timestamp_from' => $entry['timestamp'], 'timestamp_to' => $entry['timestamp']);
$entry_title = htmlentities('[' . $entry_device['hostname'] . '] ' . $entry['message']);
$entry_description = htmlentities('[' . $entry_device['hostname'] . "]\n" . strtoupper($entry['type']) . ': ' . $entry['message']);
$entry_link = $base_url . '/' . generate_device_url($entry_device, $entry_vars);
$entry_id = $entry_link . 'guid=' . md5($entry['event_id']);
if ($use_rss) {
// add item element for each article
$item = $xml->channel->addChild('item');
$item->addChild('title', $entry_title);
$item->addChild('description', $entry_description);
$item->addChild('guid', $entry_id);
$item->addChild('link', $entry_link);
$item->addChild('h:dc:creator', $entry['type']);
$item->addChild('pubDate', date(DATE_RSS, strtotime($entry['timestamp'])));
} else {
// add entry element for each article
$item = $xml->addChild('entry');
$item->addChild('title', $entry_title);
$item->addChild('summary', $entry_description);
示例12: foreach
<?php
$navbar['class'] = 'navbar-narrow subnav';
foreach ($navbar['options'] as $option => $array) {
if (!isset($vars['tab'])) {
$vars['tab'] = $option;
}
if ($vars['tab'] == $option) {
$navbar['options'][$option]['class'] .= " active";
}
if (!isset($navbar['options'][$option]['url'])) {
$navbar['options'][$option]['url'] = generate_device_url($device, array('tab' => $option));
}
if (isset($navbar['options'][$option]['suboptions'])) {
foreach ($navbar['options'][$option]['suboptions'] as $sub_option => $sub_array) {
if (!isset($navbar['options'][$option]['suboptions'][$sub_option]['url'])) {
$navbar['options'][$option]['suboptions'][$sub_option]['url'] = generate_device_url($device, array('tab' => $sub_option));
}
}
}
}
if ($vars['tab'] == 'port') {
$navbar['options']['ports']['class'] .= " active";
}
if ($vars['tab'] == 'alert') {
$navbar['options']['alerts']['class'] .= " active";
}
if ($vars['tab'] == 'accesspoint') {
$navbar['options']['accesspoints']['class'] .= " active";
}
print_navbar($navbar);
unset($navbar);
示例13: generate_device_link
function generate_device_link($device, $text = NULL, $vars = array(), $start = 0, $end = 0)
{
$class = devclass($device);
if (!$text) {
$text = $device['hostname'];
}
# $contents = generate_device_link_contents($device, $vars, $start, $end);
$text = htmlentities($text);
$url = generate_device_url($device, $vars);
$link = overlib_link($url, $text, $contents, $class);
if (!device_permitted($device['device_id'])) {
return $device['hostname'];
}
return '<a href="' . $url . '" class="entity-popup ' . $class . '" data-eid="' . $device['device_id'] . '" data-etype="device">' . $text . '</a>';
}
示例14: foreach
echo "</th>";
}
echo " </tr></thead>";
$ports_disabled = 0;
$ports_down = 0;
$ports_up = 0;
$ports_total = 0;
foreach ($ports as $port) {
$device = device_by_id_cache($port['device_id']);
#&$GLOBALS['cache']['devices']['id'][$port['device_id']];
$ports_total++;
humanize_port($port);
$error_img = '';
if ($port['in_errors'] > 0 || $port['out_errors'] > 0) {
$error_img = generate_port_link($port, "<img src='images/16/chart_curve_error.png' alt='接口错误' border=0>", 'errors');
}
if (in_array($port['port_id'], $cache['ports']['cbqos'])) {
$error_img .= '<a href="' . generate_port_url($port, array('view' => 'cbqos')) . '"><span class="label label-info">CBQoS</span></a>';
}
if (in_array($port['port_id'], $cache['ports']['pseudowires'])) {
$error_img .= '<a href="' . generate_device_url($port, array('tab' => 'pseudowires')) . '"><span class="label label-info">伪流量</span></a>';
}
$port['bps_in'] = formatRates($port['ifInOctets_rate'] * 8);
$port['bps_out'] = formatRates($port['ifOutOctets_rate'] * 8);
$port['pps_in'] = format_si($port['ifInUcastPkts_rate']) . "pps";
$port['pps_out'] = format_si($port['ifOutUcastPkts_rate']) . "pps";
echo "<tr class='ports " . $port['row_class'] . "'>\n <td class='state-marker'></td>\n <td></td>\n <td><span class=entity>" . generate_device_link($device, short_hostname($device['hostname'], "20")) . "</span><br />\n <span class=em>" . escape_html(truncate($port['location'], 32, "")) . "</span></td>\n\n <td><span class=entity>" . generate_port_link($port, rewrite_ifname($port['label'])) . " " . $error_img . "</span><br />\n <span class=em>" . escape_html(truncate($port['ifAlias'], 50, '')) . "</span></td>" . '<td> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . formatRates($port['in_rate']) . '</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . formatRates($port['out_rate']) . '</span><br /></td>' . '<td> <i class="icon-circle-arrow-down" style="' . $port['bps_in_style'] . '"></i> <span class="small" style="' . $port['bps_in_style'] . '">' . $port['ifInOctets_perc'] . '%</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['bps_out_style'] . '"></i> <span class="small" style="' . $port['bps_out_style'] . '">' . $port['ifOutOctets_perc'] . '%</span><br /></td>' . '<td><i class="icon-circle-arrow-down" style="' . $port['pps_in_style'] . '"></i> <span class="small" style="' . $port['pps_in_style'] . '">' . format_bi($port['ifInUcastPkts_rate']) . 'pps</span><br />' . '<i class="icon-circle-arrow-up" style="' . $port['pps_out_style'] . '"></i> <span class="small" style="' . $port['pps_out_style'] . '">' . format_bi($port['ifOutUcastPkts_rate']) . 'pps</span></td>' . "<td>" . $port['human_speed'] . "<br />" . $port['ifMtu'] . "</td>\n <td >" . $port['human_type'] . "<br />" . $port['human_mac'] . "</td>\n </tr>\n";
}
echo '</table>';
echo pagination($vars, $ports_count);
// EOF
示例15: dbFetchCell
} else {
if ($result['status'] == 0 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#ff0000';
} else {
if ($result['status'] == 1 && $result['ignore'] == 0 && $result['disabled'] == 0) {
$highlight_colour = '#008000';
}
}
}
}
if (is_admin() === true || is_read() === true) {
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` WHERE device_id = ?', array($result['device_id']));
} else {
$num_ports = dbFetchCell('SELECT COUNT(*) FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P` WHERE `P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id` AND `I`.`device_id` = `D`.`device_id` AND device_id = ?', array($_SESSION['user_id'], $result['device_id']));
}
$device[] = array('name' => $name, 'device_id' => $result['device_id'], 'url' => generate_device_url($result), 'colours' => $highlight_colour, 'device_ports' => $num_ports, 'device_image' => getImageSrc($result), 'device_hardware' => $result['hardware'], 'device_os' => $config['os'][$result['os']]['text'], 'version' => $result['version'], 'location' => $result['location']);
}
//end foreach
}
//end if
$json = json_encode($device);
die($json);
} else {
if ($_REQUEST['type'] == 'ports') {
// Search ports
if (is_admin() === true || is_read() === true) {
$results = dbFetchRows("SELECT `ports`.*,`devices`.* FROM `ports` LEFT JOIN `devices` ON `ports`.`device_id` = `devices`.`device_id` WHERE `ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%' OR `ifName` LIKE '%" . $search . "%' ORDER BY ifDescr LIMIT " . $limit);
} else {
$results = dbFetchRows("SELECT DISTINCT(`I`.`port_id`), `I`.*, `D`.`hostname` FROM `ports` AS `I`, `devices` AS `D`, `devices_perms` AS `P`, `ports_perms` AS `PP` WHERE ((`P`.`user_id` = ? AND `P`.`device_id` = `D`.`device_id`) OR (`PP`.`user_id` = ? AND `PP`.`port_id` = `I`.`port_id` AND `I`.`device_id` = `D`.`device_id`)) AND `D`.`device_id` = `I`.`device_id` AND (`ifAlias` LIKE '%" . $search . "%' OR `ifDescr` LIKE '%" . $search . "%' OR `ifName` LIKE '%" . $search . "%') ORDER BY ifDescr LIMIT " . $limit, array($_SESSION['user_id'], $_SESSION['user_id']));
}
if (count($results)) {