/** * Fungsi untuk men-set nilai option sesuai dengan nama / key nya * jika key sudah ada => update * jika key belum ada => insert * * @param $name * @param $value * @param string $object * @return bool */ function set_option($name, $value, $object = '') { $query = 'SELECT * FROM `' . $this->table_name . '` WHERE name = "' . $name . '"'; if ('' != $object) { $query .= ' AND object = "' . $object . '"'; } $obj_option = mysql_fetch_object(mysql_query($query)); if ($obj_option) { return parent::update($this->table_name, array('value'), array($value), array('id', $obj_option->id)); } else { return parent::insert($this->table_name, array('name', 'value', 'object'), array(array($name, $value, $object))); } }
<?php if (POST('insert')) { 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", "newdbsform.php?" . $get_param); die; } $db = new ossim_db(); $conn = $db->connect(); $icon = ""; if (is_uploaded_file($HTTP_POST_FILES['icon']['tmp_name'])) { $icon = file_get_contents($HTTP_POST_FILES['icon']['tmp_name']); } Databases::insert($conn, $dbs_name, $ip, $port, $user, $pass, $icon); $db->close($conn); if (isset($_SESSION['_dbs'])) { unset($_SESSION['_dbs']); } } ?> <p> <?php echo gettext("Database server succesfully inserted"); ?> </p> <?php if ($_SESSION["menu_sopc"] == "DBs" && POST('withoutmenu') != "1") { ?> <script type='text/javascript'>document.location.href="dbs.php";</script><?php
// 3.1) MERGE TEMP TO ORIGINAL SNORT if (!$nomerge) { $cmdline = "mysqldump -p{$snort_pass} -n -t -f --no-autocommit --insert-ignore snort_restore_{$filter_by} | mysql -u{$snort_user} -p{$snort_pass} -h{$snort_host} -P{$snort_port} {$snort_name}"; if ($debug) { echo "Merge events into snort database..."; } system($cmdline); if ($debug) { echo "ok\n"; } // 3.2) CREATE A NEW Database Profile for SIEM } else { if ($debug) { echo "Creating Database Profile..."; } $list = Databases::get_list($conn, "WHERE name='{$snort_name_temp}'"); if (count($list) < 1) { Databases::insert($conn, $snort_name_temp, $snort_host, $snort_port, $snort_user, $snort_pass, ""); if ($debug) { echo "ok\n"; } } else { if ($debug) { echo "already exists\n"; } } } if ($debug) { echo "All Done.\n"; } $conn->disconnect();