本文整理汇总了PHP中Asset_host::get_ctx_by_id方法的典型用法代码示例。如果您正苦于以下问题:PHP Asset_host::get_ctx_by_id方法的具体用法?PHP Asset_host::get_ctx_by_id怎么用?PHP Asset_host::get_ctx_by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Asset_host
的用法示例。
在下文中一共展示了Asset_host::get_ctx_by_id方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _
$data['data'] = _('Your changes have been saved');
$validation_errors = validate_form_fields('POST', $validate);
if (is_array($validation_errors) && !empty($validation_errors)) {
//Formatted message
$error_msg = '<div>' . _('The following errors occurred') . ":</div>\n <div style='padding: 5px;'>" . implode('<br/>', $validation_errors) . '</div>';
Util::response_bad_request($error_msg);
} else {
try {
$db = new ossim_db();
$conn = $db->connect();
$asset_id = POST('asset_id');
$protocol = POST('s_protocol');
$protocol_name = Protocol::get_protocol_by_number($protocol);
$port = POST('s_port');
$service = POST('s_name');
$ctx = Asset_host::get_ctx_by_id($conn, $asset_id);
$n_ports = Port::get_list($conn, " AND port_number = {$port} and protocol_name = '{$protocol_name}'");
if (count($n_ports) == 0) {
Port::insert($conn, $port, $protocol_name, $service, '', $ctx);
} else {
$data['status'] = 'warning';
$data['data'] = _('Warning! This port has already been added');
}
$db->close();
} catch (Exception $e) {
Util::response_bad_request(_('Error! Your changes could not be saved'));
}
}
break;
//Asset properties, MAC address, Software and Services
//Asset properties, MAC address, Software and Services
示例2: ini_set
* Otherwise you can read it here: http://www.gnu.org/licenses/gpl-2.0.txt
*
*/
ini_set('include_path', '/usr/share/ossim/include');
require_once 'av_init.php';
$option = $argv[1];
$asset = $argv[2];
$result = '';
$db = new ossim_db();
$dbconn = $db->connect();
$_SESSION['_user'] = 'admin';
switch ($option) {
case 'get_ctx':
if (preg_match("/^([a-f\\d]{32})#\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\$/i", $asset, $found)) {
// host_id#IP
$result = Asset_host::get_ctx_by_id($dbconn, $found[1]);
} else {
if (preg_match("/^([a-f\\d]{32})#\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\/\\d{1,2}\$/i", $asset, $found)) {
// net_id#CIDR
$result = Asset_net::get_ctx_by_id($dbconn, $found[1]);
} else {
$filters = array('where' => 'hostname = "' . $asset . '" OR fqdns LIKE "%' . $asset . '%"');
$_hosts_data = Asset_host::get_basic_list($dbconn, $filters);
$hosts_list = $_hosts_data[1];
$total = count($hosts_list);
if ($total > 0) {
$host_id = key($hosts_list);
$result = $hosts_list[$host_id]['ctx'];
} else {
$result = '';
}