From 8f9b4a045f4dd2534b22cb8e9f1828dc384b1651 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 16 May 2013 15:43:16 +0000 Subject: [PATCH] 2013-05-16 Miguel de Dios * 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 --- pandora_console/ChangeLog | 14 ++ .../agentes/module_manager_editor_common.php | 5 +- pandora_console/include/db/oracle.php | 126 ++++++++++-------- pandora_console/include/functions.php | 26 ++-- pandora_console/include/functions_html.php | 2 +- 5 files changed, 101 insertions(+), 72 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 310f1be287..bbc1c73b2f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,17 @@ +2013-05-16 Miguel de Dios + + * 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 * include/functions_networkmap.php, include/functions_reporting.php, diff --git a/pandora_console/godmode/agentes/module_manager_editor_common.php b/pandora_console/godmode/agentes/module_manager_editor_common.php index 6fe0adcb08..e59188b16e 100644 --- a/pandora_console/godmode/agentes/module_manager_editor_common.php +++ b/pandora_console/godmode/agentes/module_manager_editor_common.php @@ -128,7 +128,10 @@ $table_simple->colspan[5][1] = 3; $table_simple->colspan[6][1] = 3; $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)) { $table_simple->data[0][1] .= '  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') { - 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 { - 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 { @@ -405,7 +416,7 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) { else if (is_float ($value) || is_double ($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)); } else { @@ -434,7 +445,7 @@ function oracle_db_process_sql_insert($table, $values, $autocommit = true) { * @return string String cleaned. */ 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') { if (! is_array ($filter) || empty ($filter)) return false; - + /* Avoid limit and offset if given */ unset ($filter['limit']); unset ($filter['offset']); - + $sql = sprintf ("SELECT * FROM (SELECT %s FROM %s WHERE %s) WHERE rownum < 2", $field, $table, db_format_array_where_clause_sql ($filter, $where_join)); $result = db_get_all_rows_sql ($sql); - + if ($result === false) return false; - + $fieldClean = str_replace('`', '', $field); - + return $result[0][$fieldClean]; } @@ -771,7 +782,7 @@ function oracle_recode_query ($sql, $values, $join = 'AND', $return = true) { if (is_numeric ($field)) { /* User provide the exact operation to do */ $query .= $value; - + if ($i < $max) { $query .= ' '.$join.' '; } @@ -951,7 +962,7 @@ function oracle_db_get_all_rows_filter ($table, $filter = array(), $fields = fal $fields = '*'; } elseif (is_array($fields)) { - $fields = implode(' , ', $fields) ; + $fields = implode(' , ', $fields); } elseif (!is_string($fields)) { 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 */ $sql = sprintf ("%s = %s", $field, str_replace('`', '', $value)); else if (substr($value, 0,1) == '#'){ - $sql = sprintf ("%s = %s", $field, substr($value,1)); + $sql = sprintf ("%s = %s", $field, substr($value,1)); } else{ $sql = sprintf ("%s = '%s'", $field, $value); @@ -1153,6 +1164,7 @@ function oracle_db_process_sql_update($table, $values, $where = false, $where_jo } } $status = ''; + 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) { global $config; - if ($new == true){ + if ($new == true) { $result = oci_parse($config['dbconnection'], $sql); oci_execute($result); } @@ -1250,7 +1262,7 @@ function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) $result_temp = array(); if ($row) { - foreach ($row as $key => $value){ + foreach ($row as $key => $value) { $column_type = oci_field_type($result, $key); // Support for Clob field larger than 4000bytes 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); } @@ -1283,7 +1295,7 @@ function oracle_db_get_all_row_by_steps_sql($new = true, &$result, $sql = null) */ function oracle_db_process_sql_begin() { global $config; - + $query = oci_parse($config['dbconnection'], 'SET TRANSACTION READ WRITE'); oci_execute($query); oci_free_statement($query); @@ -1294,7 +1306,7 @@ function oracle_db_process_sql_begin() { */ function oracle_db_process_sql_commit() { global $config; - + oci_commit($config['dbconnection']); } @@ -1303,7 +1315,7 @@ function oracle_db_process_sql_commit() { */ function oracle_db_process_sql_rollback() { global $config; - + oci_rollback($config['dbconnection']); } @@ -1365,13 +1377,14 @@ function oracle_get_system_time() { */ function oracle_db_get_type_field_table($table, $field) { global $config; - - $query = oci_parse($config['dbconnection'], "SELECT * FROM " . $table . " WHERE rownum < 2"); - oci_execute($query); - + + $query = oci_parse($config['dbconnection'], + "SELECT * FROM " . $table . " WHERE rownum < 2"); + oci_execute($query); + $type = oci_field_type($query, $field+1); - oci_free_statement($query); - + oci_free_statement($query); + 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. */ function oracle_list_all_field_table($table_name, $return_mode = 'array'){ - if (empty($table_name)){ + if (empty($table_name)) { return false; } - + $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; } $field_list = array(); - foreach ($fields_info as $field){ - if ($field['data_type'] == 'CLOB'){ + foreach ($fields_info as $field) { + if ($field['data_type'] == 'CLOB') { $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']); } } // Return as comma separated string - if ($return_mode == 'string'){ + if ($return_mode == 'string') { return implode(',', $field_list); } // Return as array - else{ + else { 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) { global $config; - + $history_count = 0; $count = oracle_db_get_value_sql ($sql); if ($count === false) { $count = 0; } - + // Search the history DB for matches if ($search_history_db && $config['history_db_enabled'] == 1) { - + // Connect to the history DB 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); @@ -1443,10 +1456,9 @@ function oracle_db_get_table_count($sql, $search_history_db = false) { } } } - + $count += $history_count; - + return $count; } - -?> +?> \ No newline at end of file diff --git a/pandora_console/include/functions.php b/pandora_console/include/functions.php index 1ee506d465..aaeb97e8a5 100644 --- a/pandora_console/include/functions.php +++ b/pandora_console/include/functions.php @@ -1723,19 +1723,19 @@ function copy_dir($src, $dst) { * Looks for two or more carriage returns. */ -function is_snapshot_data ($data){ - - // 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 - // a snapshot. I think two or three is a good value anyway. - - $temp = array(); - $count = preg_match_all ("/\n/", $data, $temp); - - if ($count > 2) - return 1; - else - return 0; +function is_snapshot_data ($data) { + + // 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 + // a snapshot. I think two or three is a good value anyway. + + $temp = array(); + $count = preg_match_all ("/\n/", $data, $temp); + + if ($count > 2) + return 1; + else + return 0; } /** diff --git a/pandora_console/include/functions_html.php b/pandora_console/include/functions_html.php index d7144fbb06..7681137ed1 100644 --- a/pandora_console/include/functions_html.php +++ b/pandora_console/include/functions_html.php @@ -927,7 +927,7 @@ function html_print_input_text ($name, $value, $alt = '', $size = 50, $maxlength if ($size == 0) $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); } /**