本文整理汇总了PHP中Host::update方法的典型用法代码示例。如果您正苦于以下问题:PHP Host::update方法的具体用法?PHP Host::update怎么用?PHP Host::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Host
的用法示例。
在下文中一共展示了Host::update方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
/**
* @see Form::save()
*/
public function save()
{
ACPForm::save();
// read form data
$this->host->title = $this->title;
$this->host->hostname = $this->hostname;
$this->host->isFallback = $this->isFallback;
$this->host->languageCode = $this->languageCode;
// save
$this->host->update();
// show success message
WCF::getTPL()->assign('success', true);
// remove cache
HostEditor::clearCache();
// call event
$this->saved();
}
示例2: import_assets_csv
//.........这里部分代码省略.........
//IP
if (!ossim_valid($param[0], OSS_IP_ADDR, 'illegal:' . _("IP"))) {
$response['line_errors'][$cont][] = array("IP", ossim_get_error_clean());
$response['status'] = false;
}
//Hostname
if (empty($param[1])) {
$param[1] = $param[0];
} else {
if (!ossim_valid($param[1], OSS_SCORE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("Hostname"))) {
$response['line_errors'][$cont][] = array("Hostname", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
}
//FQDNs
if (!empty($param[2])) {
$fqdns_list = explode(",", $param[2]);
foreach ($fqdns_list as $k => $fqdn) {
if (!ossim_valid(trim($fqdn), OSS_NULLABLE, OSS_ALPHA, OSS_PUNC, 'illegal:' . _("FQDN/Aliases"))) {
$response['line_errors'][$cont][] = array("FQDN/Aliases", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
}
}
//Description
if (!ossim_valid($param[3], OSS_NULLABLE, OSS_SCORE, OSS_ALPHA, OSS_PUNC, OSS_AT, 'illegal:' . _("Description"))) {
$response['line_errors'][$cont][] = array("Description", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
//Asset
if ($param[4] == '') {
$param[4] = 2;
} else {
if (!ossim_valid($param[4], OSS_NULLABLE, OSS_DIGIT, 'illegal:' . _("Asset value"))) {
$response['line_errors'][$cont][] = array("Asset", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
}
//NAT
if (!ossim_valid($param[5], OSS_NULLABLE, OSS_IP_ADDR, 'illegal:' . _("NAT"))) {
$response['line_errors'][$cont][] = array("NAT", ossim_get_error_clean());
$response['status'] = false;
ossim_clean_error();
}
//Sensors
$sensors = array();
if (!empty($param[6])) {
$sensor_name = array();
$list = explode(",", $param[6]);
$sensors_list = array_intersect($list, $my_allowed_sensors);
if (!empty($sensors_list)) {
foreach ($sensors_list as $sensor) {
$sensors[] = Sensor::get_sensor_name($conn, $sensor);
}
} else {
$response['line_errors'][$cont][] = array("Sensors", _("You need at least one allowed Sensor"));
$response['status'] = false;
ossim_clean_error();
}
} else {
$response['line_errors'][$cont][] = array("Sensors", _("Column Sensors is empty"));
$response['status'] = false;
ossim_clean_error();
}
$list_os = array("Windows", "Linux", "FreeBSD", "NetBSD", "OpenBSD", "MacOS", "Solaris", "Cisco", "AIX", "HP-UX", "Tru64", "IRIX", "BSD/OS", "SunOS", "Plan9", "IPhone");
//Operating System
if (!empty($param[7]) && !in_array($param[7], $list_os)) {
$param[7] = "Unknown";
}
if ($response['status'] == true) {
//Parameters
$ip = $param[0];
$hostname = $param[1];
$asset = $param[4];
$threshold_c = 30;
$threshold_a = 30;
$rrd_profile = "";
$alert = 0;
$persistence = 0;
$nat = $param[5];
$descr = $param[3];
$os = $param[7];
$fqdns = $param[2];
$latitude = '';
$longitude = '';
$icon = 0;
if (!Host::in_host($conn, $ip)) {
Host::insert($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude, $fqdns, $icon);
} else {
Host::update($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, $longitude, $fqdns, $icon);
}
}
}
$response['read_line'] = $cont;
return $response;
}
示例3: update_db
function update_db($global_info, $scan)
{
$db = new ossim_db();
$conn = $db->connect();
$array_os = array("win" => "1", "linux" => "2", "cisco" => "3", "freebsd" => "5", "netbsd" => "6", "openbsd" => "7", "hp-ux" => "8", "solaris" => "9", "macos" => "10", "plan9" => "11", "sco" => "12", "aix" => "13", "unix" => "14");
$ips = $global_info["ips"];
$sensors = $global_info["sboxs"];
$nagios = $global_info['nagios'];
// load protocol ids
$protocol_ids = array();
if ($protocol_list = Protocol::get_list($conn)) {
foreach ($protocol_list as $protocol_data) {
$protocol_ids[$protocol_data->get_name()] = $protocol_data->get_id();
}
}
for ($i = 0; $i < $ips; $i++) {
$ip = $global_info["ip_{$i}"];
if (!empty($ip)) {
$hosts[] = $ip;
//gethostbyaddr($ip);
$os = $scan[$ip]["os"];
$os_id = 0;
foreach ($array_os as $k => $v) {
if (preg_match("/{$k}/i", $os)) {
$os_id = $v;
break;
}
}
if (Host::in_host($conn, $ip)) {
echo "* " . gettext("Updating") . " {$ip}..<br/>";
Host::update($conn, $ip, gethostbyaddr($ip), $global_info["asset"], $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], 0, 0, $global_info["nat"], $sensors, $global_info["descr"], $scan["{$ip}"]["os"], $scan["{$ip}"]["mac"], $scan["{$ip}"]["mac_vendor"]);
Host_scan::delete($conn, $ip, 3001);
//if (isset($global_info["nessus"])) { Host_scan::insert($conn, $ip, 3001, 0); }
} else {
echo "<span style='color='blue'>\n";
echo "* " . gettext("Inserting") . " {$ip}..<br/>\n";
echo "</span>\n";
Host::insert($conn, $ip, gethostbyaddr($ip), $global_info["asset"], $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], 0, 0, $global_info["nat"], $sensors, $global_info["descr"], $scan[$ip]["os"], $scan[$ip]["mac"], $scan[$ip]["mac_vendor"]);
// if (isset($global_info["nessus"])) { Host_scan::insert($conn, $ip, 3001, 0); }
}
if ($os_id != 0) {
Host_plugin_sid::delete($conn, $ip, 5001);
Host_plugin_sid::insert($conn, $ip, 5001, $os_id);
}
if (!empty($nagios)) {
if (!Host_scan::in_host_scan($conn, $ip, 2007)) {
Host_scan::insert($conn, $ip, 2007, "", $ip, $sensors, "");
}
} else {
if (Host_scan::in_host_scan($conn, $ip, 2007)) {
Host_scan::delete($conn, $ip, 2007);
}
}
/* Services */
Host_plugin_sid::delete($conn, $ip, 5002);
foreach ($scan[$ip]["services"] as $port_proto => $service) {
$service["proto"] = $protocol_ids[strtolower(trim($service["proto"]))];
Host_services::insert($conn, $ip, $service["port"], strftime("%Y-%m-%d %H:%M:%S"), $_SERVER["SERVER_ADDR"], $service["proto"], $service["service"], $service["service"], $service["version"], 1);
Host_plugin_sid::insert($conn, $ip, 5002, $service["port"]);
}
flush();
}
}
// Insert group name
$groupname = $global_info["groupname"];
if (!empty($groupname) && !empty($hosts)) {
$exists_hosts = count(Host_group::get_list($conn, " AND g.name='{$groupname}'")) > 0;
if ($exists_hosts) {
echo "<br/>" . _("The group name already exists") . "<br/>";
} else {
Host_group::insert($conn, $groupname, $global_info["threshold_c"], $global_info["threshold_a"], $global_info["rrd_profile"], $sensors, $hosts, $global_info["descr"]);
}
//if (isset($global_info["nessus"])) { Host_group_scan::insert($conn, $groupname, 3001, 0); }
if (!empty($nagios)) {
Host_group_scan::insert($conn, $groupname, 2007, 0);
}
}
$db->close($conn);
}
示例4: actionEdit
public function actionEdit()
{
$msgHost = "";
$request = Yii::app()->getRequest();
$id = trim($request->getParam("id"));
if (!empty($_POST)) {
$ip = trim($request->getPost("ip"));
$admin = trim($request->getPost("admin"));
$username = trim($request->getPost("username"));
$password = trim($request->getPost("password"));
$provider = trim($request->getPost("provider"));
$status = trim($request->getPost("status"));
if ($ip == "") {
$msgHost = "主机IP选项不能留空";
} else {
if (strlen($ip) > 64) {
$msgHost = "输入不能大于64个字符";
}
}
if ($msgHost == "") {
$host = array('ip' => $ip, 'admin' => $admin, 'username' => $username, 'password' => $password, 'provider' => $provider, 'status' => $status);
try {
$res = new Host();
$res->_pk = $id;
$res->_attributes = $host;
$res->setIsNewRecord(false);
$res->update();
$this->redirect(array('list'));
} catch (CDbException $e) {
throw CDbException($e);
}
}
}
try {
$Rs = new Host();
$rsInfo = $Rs->findByPk($id);
} catch (CDbException $e) {
throw CDbException($e);
}
$this->render('edit', array('r' => Yii::app()->request->baseUrl . '/', 'rsInfo' => $rsInfo, 'msgHost' => $msgHost));
}
示例5: _
if (POST('withoutmenu') != "1") {
include "../hmenu.php";
$get_param = "ip={$ip}";
} else {
$get_param = "ip={$ip}&withoutmenu=1";
}
if (POST('insert') && !empty($ip)) {
if ($error == true) {
$txt_error = "<div>" . _("We Found the following errors") . ":</div><div style='padding:10px;'>" . implode("<br/>", $message_error) . "</div>";
Util::print_error($txt_error);
Util::make_form("POST", "modifyhostform.php?" . $get_param);
die;
}
$db = new ossim_db();
$conn = $db->connect();
Host::update($conn, $ip, $hostname, $asset, $threshold_c, $threshold_a, $rrd_profile, $alert, $persistence, $nat, $sensors, $descr, $os, $mac, $mac_vendor, $latitude, "{$longitude};{$zoom}", $fqdns, $icon);
if ($hostname != $old_hostname) {
$query = "UPDATE risk_indicators SET type_name=? WHERE type='host' AND type_name=?";
$params = array($hostname, $hostname_old);
$conn->Execute($query, $params);
}
Host_scan::delete($conn, $ip, 3001);
Host_scan::delete($conn, $ip, 2007);
//if (!empty($nessus)) Host_scan::insert($conn, $ip, 3001);
Host_scan::delete($conn, $ip, 3001);
if (!empty($nagios)) {
if (!Host_scan::in_host_scan($conn, $ip, 2007)) {
Host_scan::insert($conn, $ip, 2007, "", $hostname, $sensors, $sensors);
}
} else {
if (Host_scan::in_host_scan($conn, $ip, 2007)) {