2013-05-16 Miguel de Dios <miguel.dedios@artica.es>

* godmode/agentes/module_manager_editor_common.php: disabled
	autocomplete for the field name to avoid javascript problems.
	
	Fixes: #2215
	
	* include/db/oracle.php, include/functions.php: improved the source
	code style.
	
	* include/functions_html.php: fixed the lost parameter $alt for
	the function html_print_input_text_extended from
	html_print_input_text.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8145 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-05-16 15:43:16 +00:00
parent c999a888b9
commit 8f9b4a045f
5 changed files with 101 additions and 72 deletions

View File

@ -1,3 +1,17 @@
2013-05-16 Miguel de Dios <miguel.dedios@artica.es>
* godmode/agentes/module_manager_editor_common.php: disabled
autocomplete for the field name to avoid javascript problems.
Fixes: #2215
* include/db/oracle.php, include/functions.php: improved the source
code style.
* include/functions_html.php: fixed the lost parameter $alt for
the function html_print_input_text_extended from
html_print_input_text.
2013-05-16 Miguel de Dios <miguel.dedios@artica.es> 2013-05-16 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_networkmap.php, include/functions_reporting.php, * include/functions_networkmap.php, include/functions_reporting.php,

View File

@ -128,7 +128,10 @@ $table_simple->colspan[5][1] = 3;
$table_simple->colspan[6][1] = 3; $table_simple->colspan[6][1] = 3;
$table_simple->data[0][0] = __('Name'); $table_simple->data[0][0] = __('Name');
$table_simple->data[0][1] = html_print_input_text ('name', io_safe_output($name), '', 45, 100, true, $disabledBecauseInPolicy); $table_simple->data[0][1] = html_print_input_text_extended ('name',
io_safe_output($name), 'text-'.$name, '', 45, 100, $disabledBecauseInPolicy, '', 'autocomplete="off"', true);
//$table_simple->data[0][1] = html_print_input_text ('name',
// io_safe_output($name), '', 45, 100, true, $disabledBecauseInPolicy);
if (!empty($id_agent_module) && isset($id_agente)) { if (!empty($id_agent_module) && isset($id_agente)) {
$table_simple->data[0][1] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$id_agent_module.'" $table_simple->data[0][1] .= '&nbsp;<a href="index.php?sec=gagente&tab=module&sec2=godmode/agentes/configurar_agente&id_agente='.$id_agente.'&delete_module='.$id_agent_module.'"

View File

@ -34,18 +34,18 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null,
if (! $connect_id) { if (! $connect_id) {
return false; return false;
} }
// Set date and timestamp formats for this session // Set date and timestamp formats for this session
$datetime_tz_format = oci_parse($connect_id , 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); $datetime_tz_format = oci_parse($connect_id , 'alter session set NLS_TIMESTAMP_TZ_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$datetime_format = oci_parse($connect_id , 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); $datetime_format = oci_parse($connect_id , 'alter session set NLS_TIMESTAMP_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$date_format = oci_parse($connect_id , 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\''); $date_format = oci_parse($connect_id , 'alter session set NLS_DATE_FORMAT =\'YYYY-MM-DD HH24:MI:SS\'');
$decimal_separator = oci_parse($connect_id , 'alter session set NLS_NUMERIC_CHARACTERS =\',.\''); $decimal_separator = oci_parse($connect_id , 'alter session set NLS_NUMERIC_CHARACTERS =\',.\'');
oci_execute($datetime_tz_format); oci_execute($datetime_tz_format);
oci_execute($datetime_format); oci_execute($datetime_format);
oci_execute($date_format); oci_execute($date_format);
oci_execute($decimal_separator); oci_execute($decimal_separator);
oci_free_statement($datetime_tz_format); oci_free_statement($datetime_tz_format);
oci_free_statement($datetime_format); oci_free_statement($datetime_format);
oci_free_statement($date_format); oci_free_statement($date_format);
@ -67,18 +67,24 @@ function oracle_connect_db($host = null, $db = null, $user = null, $pass = null,
function oracle_db_get_value ($field, $table, $field_search = 1, $condition = 1, $search_history_db = false) { function oracle_db_get_value ($field, $table, $field_search = 1, $condition = 1, $search_history_db = false) {
if (is_int ($condition)) { if (is_int ($condition)) {
$sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s = %d) WHERE rownum < 2", $sql = sprintf ("SELECT *
$field, $table, $field_search, $condition); FROM (SELECT %s FROM %s WHERE %s = %d)
WHERE rownum < 2",
$field, $table, $field_search, $condition);
} }
else if (is_float ($condition) || is_double ($condition)) { else if (is_float ($condition) || is_double ($condition)) {
$sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s = %f) WHERE rownum < 2", $sql = sprintf ("SELECT *
$field, $table, $field_search, $condition); FROM (SELECT %s FROM %s WHERE %s = %f)
WHERE rownum < 2",
$field, $table, $field_search, $condition);
} }
else { else {
$sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s = '%s') WHERE rownum < 2", $sql = sprintf ("SELECT *
$field, $table, $field_search, $condition); FROM (SELECT %s FROM %s WHERE %s = '%s')
WHERE rownum < 2",
$field, $table, $field_search, $condition);
} }
$result = db_get_all_rows_sql ($sql, $search_history_db); $result = db_get_all_rows_sql ($sql, $search_history_db);
if ($result === false) if ($result === false)
@ -86,7 +92,7 @@ function oracle_db_get_value ($field, $table, $field_search = 1, $condition = 1,
if ($field[0] == '`') if ($field[0] == '`')
$field = str_replace ('`', '', $field); $field = str_replace ('`', '', $field);
if (!isset($result[0][$field])) { if (!isset($result[0][$field])) {
return reset($result[0]); return reset($result[0]);
} }
@ -132,7 +138,7 @@ function oracle_db_get_row ($table, $field_search, $condition, $fields = false)
$fields, $table, $field_search, $condition); $fields, $table, $field_search, $condition);
} }
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
if ($result === false) if ($result === false)
return false; return false;
@ -143,11 +149,11 @@ function oracle_db_get_all_rows_sql ($sql, $search_history_db = false, $cache =
global $config; global $config;
$history = array (); $history = array ();
if ($dbconnection === false) { if ($dbconnection === false) {
$dbconnection = $config['dbconnection']; $dbconnection = $config['dbconnection'];
} }
// To disable globally SQL cache depending on global variable. // To disable globally SQL cache depending on global variable.
// Used in several critical places like Metaconsole trans-server queries // Used in several critical places like Metaconsole trans-server queries
if (isset($config["dbcache"])) if (isset($config["dbcache"]))
@ -175,14 +181,14 @@ function oracle_db_get_all_rows_sql ($sql, $search_history_db = false, $cache =
if ($return === false) { if ($return === false) {
$return = array (); $return = array ();
} }
// Append result to the history DB data // Append result to the history DB data
if (! empty ($return)) { if (! empty ($return)) {
foreach ($return as $row) { foreach ($return as $row) {
array_push ($history, $row); array_push ($history, $row);
} }
} }
if (! empty ($history)) if (! empty ($history))
return $history; return $history;
//Return false, check with === or !== //Return false, check with === or !==
@ -355,12 +361,17 @@ function oracle_db_get_all_rows_in_table($table, $order_field = "", $order = 'AS
if ($order_field != "") { if ($order_field != "") {
// Clob fields are not allowed in ORDER BY statements, they need cast to varchar2 datatype // Clob fields are not allowed in ORDER BY statements, they need cast to varchar2 datatype
$type = db_get_value_filter ('data_type', 'user_tab_columns', array ('table_name' => strtoupper($table), 'column_name' => strtoupper($order_field)), 'AND'); $type = db_get_value_filter ('data_type', 'user_tab_columns',
array ('table_name' => strtoupper($table), 'column_name' => strtoupper($order_field)), 'AND');
if ($type == 'CLOB') { if ($type == 'CLOB') {
return db_get_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY dbms_lob.substr(' . $order_field . ',4000,1) ' . $order); return db_get_all_rows_sql ('SELECT *
FROM ' . $table . '
ORDER BY dbms_lob.substr(' . $order_field . ',4000,1) ' . $order);
} }
else { else {
return db_get_all_rows_sql ('SELECT * FROM ' . $table . ' ORDER BY ' . $order_field . ' ' . $order); return db_get_all_rows_sql ('SELECT *
FROM ' . $table . '
ORDER BY ' . $order_field . ' ' . $order);
} }
} }
else { else {
@ -405,7 +416,7 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) {
else if (is_float ($value) || is_double ($value)) { else if (is_float ($value) || is_double ($value)) {
$values_str .= sprintf("%f", $value); $values_str .= sprintf("%f", $value);
} }
else if (substr($value,0,1) == '#'){ else if (substr($value,0,1) == '#') {
$values_str .= sprintf("%s", substr($value,1)); $values_str .= sprintf("%s", substr($value,1));
} }
else { else {
@ -434,7 +445,7 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) {
* @return string String cleaned. * @return string String cleaned.
*/ */
function oracle_escape_string_sql($string) { function oracle_escape_string_sql($string) {
return str_replace(array('"', "'", '\\'), array('\\"', '\\\'', '\\\\'), $string); return str_replace(array('"', "'", '\\'), array('\\"', '\\\'', '\\\\'), $string);
} }
/** /**
@ -469,21 +480,21 @@ function oracle_escape_string_sql($string) {
function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') { function oracle_db_get_value_filter ($field, $table, $filter, $where_join = 'AND') {
if (! is_array ($filter) || empty ($filter)) if (! is_array ($filter) || empty ($filter))
return false; return false;
/* Avoid limit and offset if given */ /* Avoid limit and offset if given */
unset ($filter['limit']); unset ($filter['limit']);
unset ($filter['offset']); unset ($filter['offset']);
$sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s) WHERE rownum < 2", $sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s) WHERE rownum < 2",
$field, $table, $field, $table,
db_format_array_where_clause_sql ($filter, $where_join)); db_format_array_where_clause_sql ($filter, $where_join));
$result = db_get_all_rows_sql ($sql); $result = db_get_all_rows_sql ($sql);
if ($result === false) if ($result === false)
return false; return false;
$fieldClean = str_replace('`', '', $field); $fieldClean = str_replace('`', '', $field);
return $result[0][$fieldClean]; return $result[0][$fieldClean];
} }
@ -771,7 +782,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) {
if (is_numeric ($field)) { if (is_numeric ($field)) {
/* User provide the exact operation to do */ /* User provide the exact operation to do */
$query .= $value; $query .= $value;
if ($i < $max) { if ($i < $max) {
$query .= ' '.$join.' '; $query .= ' '.$join.' ';
} }
@ -951,7 +962,7 @@ function oracle_db_get_all_rows_filter ($table, $filter = array(), $fields = fal
$fields = '*'; $fields = '*';
} }
elseif (is_array($fields)) { elseif (is_array($fields)) {
$fields = implode(' , ', $fields) ; $fields = implode(' , ', $fields);
} }
elseif (!is_string($fields)) { elseif (!is_string($fields)) {
return false; return false;
@ -1102,7 +1113,7 @@ function oracle_db_format_array_to_update_sql ($values) {
/* Don't round with quotes if it references a field */ /* Don't round with quotes if it references a field */
$sql = sprintf ("%s = %s", $field, str_replace('`', '', $value)); $sql = sprintf ("%s = %s", $field, str_replace('`', '', $value));
else if (substr($value, 0,1) == '#'){ else if (substr($value, 0,1) == '#'){
$sql = sprintf ("%s = %s", $field, substr($value,1)); $sql = sprintf ("%s = %s", $field, substr($value,1));
} }
else{ else{
$sql = sprintf ("%s = '%s'", $field, $value); $sql = sprintf ("%s = '%s'", $field, $value);
@ -1153,6 +1164,7 @@ function oracle_db_process_sql_update($table, $values, $where = false, $where_jo
} }
} }
$status = ''; $status = '';
return db_process_sql ($query, "affected_rows", '', true, $status, $autocommit); return db_process_sql ($query, "affected_rows", '', true, $status, $autocommit);
} }
@ -1242,7 +1254,7 @@ function oracle_db_process_sql_delete_temp ($table, $where, $where_join = 'AND')
function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) { function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) {
global $config; global $config;
if ($new == true){ if ($new == true) {
$result = oci_parse($config['dbconnection'], $sql); $result = oci_parse($config['dbconnection'], $sql);
oci_execute($result); oci_execute($result);
} }
@ -1250,7 +1262,7 @@ function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null)
$result_temp = array(); $result_temp = array();
if ($row) { if ($row) {
foreach ($row as $key => $value){ foreach ($row as $key => $value) {
$column_type = oci_field_type($result, $key); $column_type = oci_field_type($result, $key);
// Support for Clob field larger than 4000bytes // Support for Clob field larger than 4000bytes
if ($column_type == 'CLOB') { if ($column_type == 'CLOB') {
@ -1270,7 +1282,7 @@ function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null)
} }
} }
if (!$row){ if (!$row) {
oci_free_statement($result); oci_free_statement($result);
} }
@ -1283,7 +1295,7 @@ function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null)
*/ */
function oracle_db_process_sql_begin() { function oracle_db_process_sql_begin() {
global $config; global $config;
$query = oci_parse($config['dbconnection'], 'SET TRANSACTION READ WRITE'); $query = oci_parse($config['dbconnection'], 'SET TRANSACTION READ WRITE');
oci_execute($query); oci_execute($query);
oci_free_statement($query); oci_free_statement($query);
@ -1294,7 +1306,7 @@ function oracle_db_process_sql_begin() {
*/ */
function oracle_db_process_sql_commit() { function oracle_db_process_sql_commit() {
global $config; global $config;
oci_commit($config['dbconnection']); oci_commit($config['dbconnection']);
} }
@ -1303,7 +1315,7 @@ function oracle_db_process_sql_commit() {
*/ */
function oracle_db_process_sql_rollback() { function oracle_db_process_sql_rollback() {
global $config; global $config;
oci_rollback($config['dbconnection']); oci_rollback($config['dbconnection']);
} }
@ -1365,13 +1377,14 @@ function oracle_get_system_time() {
*/ */
function oracle_db_get_type_field_table($table, $field) { function oracle_db_get_type_field_table($table, $field) {
global $config; global $config;
$query = oci_parse($config['dbconnection'], "SELECT * FROM " . $table . " WHERE rownum < 2"); $query = oci_parse($config['dbconnection'],
oci_execute($query); "SELECT * FROM " . $table . " WHERE rownum < 2");
oci_execute($query);
$type = oci_field_type($query, $field+1); $type = oci_field_type($query, $field+1);
oci_free_statement($query); oci_free_statement($query);
return $type; return $type;
} }
@ -1385,30 +1398,30 @@ function oracle_db_get_type_field_table($table, $field) {
* @return mixed Return an array/string of table fields or false if something goes wrong. * @return mixed Return an array/string of table fields or false if something goes wrong.
*/ */
function oracle_list_all_field_table($table_name, $return_mode = 'array'){ function oracle_list_all_field_table($table_name, $return_mode = 'array'){
if (empty($table_name)){ if (empty($table_name)) {
return false; return false;
} }
$fields_info = db_get_all_rows_field_filter('user_tab_columns', 'table_name', strtoupper($table_name)); $fields_info = db_get_all_rows_field_filter('user_tab_columns', 'table_name', strtoupper($table_name));
if (empty($fields_info)){ if (empty($fields_info)) {
return false; return false;
} }
$field_list = array(); $field_list = array();
foreach ($fields_info as $field){ foreach ($fields_info as $field) {
if ($field['data_type'] == 'CLOB'){ if ($field['data_type'] == 'CLOB') {
$new_field = 'dbms_lob.substr(' . $field['table_name'] . '.' . $field['column_name'] . ', 4000, 1) as ' . strtolower($field['column_name']); $new_field = 'dbms_lob.substr(' . $field['table_name'] . '.' . $field['column_name'] . ', 4000, 1) as ' . strtolower($field['column_name']);
$field_list[] = $new_field; $field_list[] = $new_field;
} }
else{ else {
$field_list[] = strtolower($field['table_name'] . '.' . $field['column_name']); $field_list[] = strtolower($field['table_name'] . '.' . $field['column_name']);
} }
} }
// Return as comma separated string // Return as comma separated string
if ($return_mode == 'string'){ if ($return_mode == 'string') {
return implode(',', $field_list); return implode(',', $field_list);
} }
// Return as array // Return as array
else{ else {
return $field_list; return $field_list;
} }
} }
@ -1422,16 +1435,16 @@ function oracle_list_all_field_table($table_name, $return_mode = 'array'){
*/ */
function oracle_db_get_table_count($sql, $search_history_db = false) { function oracle_db_get_table_count($sql, $search_history_db = false) {
global $config; global $config;
$history_count = 0; $history_count = 0;
$count = oracle_db_get_value_sql ($sql); $count = oracle_db_get_value_sql ($sql);
if ($count === false) { if ($count === false) {
$count = 0; $count = 0;
} }
// Search the history DB for matches // Search the history DB for matches
if ($search_history_db && $config['history_db_enabled'] == 1) { if ($search_history_db && $config['history_db_enabled'] == 1) {
// Connect to the history DB // Connect to the history DB
if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) { if (! isset ($config['history_db_connection']) || $config['history_db_connection'] === false) {
$config['history_db_connection'] = oracle_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], $config['history_db_pass'], $config['history_db_port'], false); $config['history_db_connection'] = oracle_connect_db ($config['history_db_host'], $config['history_db_name'], $config['history_db_user'], $config['history_db_pass'], $config['history_db_port'], false);
@ -1443,10 +1456,9 @@ function oracle_db_get_table_count($sql, $search_history_db = false) {
} }
} }
} }
$count += $history_count; $count += $history_count;
return $count; return $count;
} }
?>
?>

View File

@ -1723,19 +1723,19 @@ function copy_dir($src, $dst) {
* Looks for two or more carriage returns. * Looks for two or more carriage returns.
*/ */
function is_snapshot_data ($data){ function is_snapshot_data ($data) {
// TODO IDEA: In the future, we can set a variable in setup // TODO IDEA: In the future, we can set a variable in setup
// to define how many \n must have a snapshot to define it's // to define how many \n must have a snapshot to define it's
// a snapshot. I think two or three is a good value anyway. // a snapshot. I think two or three is a good value anyway.
$temp = array(); $temp = array();
$count = preg_match_all ("/\n/", $data, $temp); $count = preg_match_all ("/\n/", $data, $temp);
if ($count > 2) if ($count > 2)
return 1; return 1;
else else
return 0; return 0;
} }
/** /**

View File

@ -927,7 +927,7 @@ function html_print_input_text ($name, $value, $alt = '', $size = 50, $maxlength
if ($size == 0) if ($size == 0)
$size = 10; $size = 10;
return html_print_input_text_extended ($name, $value, 'text-'.$name, '', $size, $maxlength, $disabled, '', '', $return); return html_print_input_text_extended ($name, $value, 'text-'.$name, $alt, $size, $maxlength, $disabled, '', '', $return);
} }
/** /**