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

* include/functions.php,
	include/javascript/jquery.pandora.controls.js: improved the
	functions to pass the php vars to js, now it supports json.
	
	* include/javascript/d3.v3.js: added this library for to make
	beautiful things.
	
	* include/functions_ui.php, include/graphs/fgraph.php,
	include/javascript/pandora_events.js, include/javascript/pandora.js,
	include/functions_treeview.php,
	include/include_graph_dependencies.php,
	include/functions_categories.php, include/db/postgresql.php,
	include/db/oracle.php, include/db/mysql.php: cleaned source code
	style.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8528 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2013-07-16 14:13:23 +00:00
parent 3eed1ff8be
commit 0875fb0af9
14 changed files with 8943 additions and 197 deletions

View File

@ -1,3 +1,20 @@
2013-07-16 Miguel de Dios <miguel.dedios@artica.es>
* include/functions.php,
include/javascript/jquery.pandora.controls.js: improved the
functions to pass the php vars to js, now it supports json.
* include/javascript/d3.v3.js: added this library for to make
beautiful things.
* include/functions_ui.php, include/graphs/fgraph.php,
include/javascript/pandora_events.js, include/javascript/pandora.js,
include/functions_treeview.php,
include/include_graph_dependencies.php,
include/functions_categories.php, include/db/postgresql.php,
include/db/oracle.php, include/db/mysql.php: cleaned source code
style.
2013-07-16 Miguel de Dios <miguel.dedios@artica.es>
* include/graphs/flot/pandora.flot.js,

View File

@ -580,7 +580,7 @@ function mysql_db_get_value_sql($sql, $dbconnection = false) {
$sql .= " LIMIT 1";
$result = mysql_db_get_all_rows_sql ($sql, false, true, $dbconnection);
if($result === false)
if ($result === false)
return false;
foreach ($result[0] as $f)
@ -598,7 +598,7 @@ function mysql_db_get_row_sql ($sql, $search_history_db = false) {
$sql .= " LIMIT 1";
$result = db_get_all_rows_sql ($sql, $search_history_db);
if($result === false)
if ($result === false)
return false;
return $result[0];

View File

@ -861,7 +861,7 @@ function oracle_db_get_value_sql($sql, $dbconnection = false) {
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
$result = oracle_db_get_all_rows_sql ($sql, false, true, $dbconnection);
if($result === false)
if ($result === false)
return false;
foreach ($result[0] as $f)
@ -879,7 +879,7 @@ function oracle_db_get_row_sql ($sql, $search_history_db = false) {
$sql = "SELECT * FROM (" . $sql . ") WHERE rownum < 2";
$result = oracle_db_get_all_rows_sql($sql, $search_history_db);
if($result === false)
if ($result === false)
return false;
return $result[0];
@ -1115,7 +1115,7 @@ function oracle_db_format_array_to_update_sql ($values) {
else if (substr($value, 0,1) == '#'){
$sql = sprintf ("%s = %s", $field, substr($value,1));
}
else{
else {
$sql = sprintf ("%s = '%s'", $field, $value);
}
}

View File

@ -57,15 +57,15 @@ function postgresql_db_get_value ($field, $table, $field_search = 1, $condition
if (is_int ($condition)) {
$sql = sprintf ("SELECT %s FROM %s WHERE %s = %d LIMIT 1",
$field, $table, $field_search, $condition);
$field, $table, $field_search, $condition);
}
else if (is_float ($condition) || is_double ($condition)) {
$sql = sprintf ("SELECT %s FROM %s WHERE %s = %f LIMIT 1",
$field, $table, $field_search, $condition);
$field, $table, $field_search, $condition);
}
else {
$sql = sprintf ("SELECT %s FROM %s WHERE %s = '%s' LIMIT 1",
$field, $table, $field_search, $condition);
$field, $table, $field_search, $condition);
}
$result = db_get_all_rows_sql ($sql, $search_history_db);
@ -171,6 +171,7 @@ function postgresql_db_get_all_rows_sql ($sql, $search_history_db = false, $cach
if (! empty ($history))
return $history;
//Return false, check with === or !==
return false;
}
@ -247,7 +248,7 @@ function postgresql_db_process_sql($sql, $rettype = "affected_rows", $dbconnecti
$result = $rows;
}
db_add_database_debug_trace ($sql, $result, $rows,
array ('time' => $time));
array ('time' => $time));
return $result;
}
@ -613,7 +614,7 @@ function postgresql_db_get_value_sql($sql, $dbconnection = false) {
$sql .= " LIMIT 1";
$result = postgresql_db_get_all_rows_sql ($sql, false, true, $dbconnection);
if($result === false)
if ($result === false)
return false;
foreach ($result[0] as $f)
@ -631,7 +632,7 @@ function postgresql_db_get_row_sql ($sql, $search_history_db = false) {
$sql .= " LIMIT 1";
$result = postgresql_db_get_all_rows_sql($sql, $search_history_db);
if($result === false)
if ($result === false)
return false;
return $result[0];

View File

@ -138,48 +138,6 @@ function safe_url_extraclean ($string, $default_string = '') {
return $string;
}
/**
* DEPRECATED: This function is not used anywhere. Remove it?
* (use general/noaccess.php followed by exit instead)
*/
function no_permission () {
require ("config.php");
ui_print_error_message(__('You don\'t have access'));
echo html_print_image('images/noaccess.png', true, array("alt" => 'No access', "width" => '120')) . "<br /><br />";
echo "<table width=550>";
echo "<tr><td>";
echo __('You don\'t have enough permission to access this resource');
echo "</table>";
echo "<tr><td><td><td><td>";
include "general/footer.php";
exit;
}
/**
* DEPRECATED: This function is not used anywhere. Remove it?
* (use print_error function instead followed by return or exit)
*
* @param string $error Aditional error string to be shown. Blank by default
*/
function unmanaged_error ($error = "") {
require_once ("config.php");
ui_print_error_message(__('Unmanaged error'));
echo html_print_image('images/error.png', true, array("alt" => 'error')) . "<br /><br />";
echo "<table width=550>";
echo "<tr><td>";
echo __('Unmanaged error');
echo "<tr><td>";
echo $error;
echo "</table>";
echo "<tr><td><td><td><td>";
include "general/footer.php";
exit;
}
/**
* List files in a directory in the local path.
*
@ -1775,10 +1733,11 @@ function is_snapshot_data ($data) {
/**
* Create an invisible div with a provided ID and value to
* can retrieve it from javascript with function get_php_value(value)
* can retrieve it from javascript with function get_php_value(name)
*/
function set_js_value($name, $value) {
html_print_div(array('id' => 'php_to_js_value_' . $name, 'content' => $value, 'hidden' => true));
html_print_div(array('id' => 'php_to_js_value_' . $name,
'content' => json_encode($value), 'hidden' => true));
}

View File

@ -31,7 +31,7 @@ function categories_delete_category ($id_category) {
// Change the elements of this category to "without category"
db_process_sql_update('tagente_modulo', array('id_category' => 0), array('id_category' => $id_category));
db_process_sql_update('tnetwork_component', array('id_category' => 0), array('id_category' => $id_category));
if(enterprise_installed()) {
if (enterprise_installed()) {
db_process_sql_update('tlocal_component', array('id_category' => 0), array('id_category' => $id_category));
db_process_sql_update('tpolicy_modules', array('id_category' => 0), array('id_category' => $id_category));
}

View File

@ -17,7 +17,7 @@
function treeview_printModuleTable($id_module, $server_data = false) {
global $config;
if(empty($server_data)) {
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
@ -50,7 +50,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
if (! check_acl ($config["id_user"], $module["id_grupo"], "AR")) {
db_pandora_audit("ACL Violation",
"Trying to access Module Information");
"Trying to access Module Information");
require_once ("general/noaccess.php");
return;
}
@ -108,13 +108,13 @@ function treeview_printModuleTable($id_module, $server_data = false) {
// Tags
$tags = tags_get_module_tags($module['id_agente_modulo']);
if(empty($tags)) {
if (empty($tags)) {
$tags = array();
}
foreach($tags as $k => $v) {
foreach ($tags as $k => $v) {
$tag_name = tags_get_name($v);
if(empty($tag_name)) {
if (empty($tag_name)) {
unset($tags[$k]);
}
else {
@ -122,7 +122,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
}
}
if(empty($tags)) {
if (empty($tags)) {
$tags = '<i>' . __('N/A') . '</i>';
}
else {
@ -189,7 +189,7 @@ function treeview_printModuleTable($id_module, $server_data = false) {
function treeview_printAlertsTable($id_module, $server_data = array()) {
global $config;
if(empty($server_data)) {
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
@ -226,7 +226,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
echo '<td class="datos">'.$template_name.'</td>';
$actions = alerts_get_alert_agent_module_actions($module_alert['id']);
echo '<td class="datos">';
if(empty($actions)) {
if (empty($actions)) {
echo '<i>'.__('N/A').'</i>';
}
else {
@ -242,7 +242,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
}
echo '</table>';
if(can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
if (can_user_access_node () && check_acl ($config["id_user"], $id_group, 'LW')) {
// Actions table
echo '<div style="width:90%; text-align: right; min-width: 300px;">';
echo '<form id="agent_detail" method="post" action="' . $console_url . 'index.php?sec=gagente&sec2=godmode/agentes/configurar_agente&tab=alert&search=1&module_name=' . $module_name . '&id_agente=' . $agent_id . $url_hash . '" target="_blank">';
@ -255,7 +255,7 @@ function treeview_printAlertsTable($id_module, $server_data = array()) {
function treeview_printTable($id_agente, $server_data = array()) {
global $config;
if(empty($server_data)) {
if (empty($server_data)) {
$server_name = '';
$server_id = '';
$url_hash = '';
@ -283,7 +283,7 @@ function treeview_printTable($id_agente, $server_data = array()) {
$is_extra = enterprise_hook('policies_is_agent_extra_policy', array($id_agente));
if($is_extra === ENTERPRISE_NOT_HOOK) {
if ($is_extra === ENTERPRISE_NOT_HOOK) {
$is_extra = false;
}
@ -313,8 +313,8 @@ function treeview_printTable($id_agente, $server_data = array()) {
$addresses = agents_get_addresses ($id_agente);
$address = agents_get_address($id_agente);
foreach($addresses as $k => $add) {
if($add == $address) {
foreach ($addresses as $k => $add) {
if ($add == $address) {
unset($addresses[$k]);
}
}
@ -590,7 +590,7 @@ function treeview_getData ($type) {
$avariableGroups = array_intersect_key($avariableGroups, $fgroups);
$avariableGroupsIds = implode(',',array_keys($avariableGroups));
if($avariableGroupsIds == '') {
if ($avariableGroupsIds == '') {
$avariableGroupsIds == -1;
}
@ -874,7 +874,7 @@ function treeview_getData ($type) {
default:
case 'module':
$avariableGroupsIds = implode(',',array_keys($avariableGroups));
if($avariableGroupsIds == ''){
if ($avariableGroupsIds == ''){
$avariableGroupsIds == -1;
}
@ -926,7 +926,7 @@ function treeview_getData ($type) {
case 'tag':
// Restrict the tags showed to the user tags
$user_tags = tags_get_user_tags();
if(empty($user_tags)) {
if (empty($user_tags)) {
$user_tags_sql = ' AND 1 = 0';
}
else {
@ -953,7 +953,7 @@ function treeview_getData ($type) {
break;
}
if($list == false) {
if ($list == false) {
$list = array();
}
@ -1041,7 +1041,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel
//TODO CHANGE POLICY ACL FOR TAG ACL
$extra_sql = '';
if($extra_sql != '') {
if ($extra_sql != '') {
$extra_sql .= ' OR';
}
$groups_sql = implode(', ', $avariableGroupsIds);
@ -1184,7 +1184,7 @@ function treeview_getFirstBranchSQL ($type, $id, $avariableGroupsIds, $statusSel
return false;
}
if(empty($groups_sql)) {
if (empty($groups_sql)) {
$groups_condition = ' AND 1 = 0';
}
else {

View File

@ -20,7 +20,7 @@
*/
// Check to avoid error when load this library in error screen situations
if(isset($config['homedir'])) {
if (isset($config['homedir'])) {
require_once($config['homedir'] . '/include/functions_agents.php');
require_once($config['homedir'] . '/include/functions_modules.php');
require_once($config['homedir'] . '/include/functions.php');
@ -474,7 +474,7 @@ function ui_print_tags_warning ($return = false) {
$msg .= __("Is possible that this view uses part of information which your user has not access");
$msg .= '</div>';
if($return) {
if ($return) {
return $msg;
}
else {
@ -535,12 +535,12 @@ function ui_print_group_icon ($id_group, $return = false, $path = "groups_small"
* @return string HTML code if return parameter is true.
*/
function ui_print_group_icon_path ($id_group, $return = false, $path = "images/groups_small", $style='', $link = true) {
if($id_group > 0)
if ($id_group > 0)
$icon = (string) db_get_value ('icon', 'tgrupo', 'id_grupo', (int) $id_group);
else
$icon = "world";
if($style == '')
if ($style == '')
$style = 'width: 16px; height: 16px;';
$output = '';
@ -593,7 +593,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, true, $relative);
}
else {
if(!isset($options['title'])) {
if (!isset($options['title'])) {
$options['title'] = $os_name;
}
$output = html_print_image("images/" . $subfolter . "/" . $icon, true, $options, false, $relative);
@ -627,7 +627,7 @@ function ui_print_os_icon ($id_os, $name = true, $return = false, $apply_skin =
* @return string HTML with agent name and link
*/
function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_medium', $style = '', $cutname = false, $server_url = '', $extra_params = '', $known_agent_name = false) {
if($known_agent_name === false) {
if ($known_agent_name === false) {
$agent_name = (string) agents_get_name ($id_agent);
}
else {
@ -669,7 +669,7 @@ function ui_print_agent_name ($id_agent, $return = false, $cutoff = 'agent_mediu
function ui_format_alert_row ($alert, $agent = true, $url = '', $agent_style = false) {
global $config;
if(!isset($alert['server_data'])) {
if (!isset($alert['server_data'])) {
$server_name = '';
$server_id = '';
$url_hash = '';
@ -1004,7 +1004,7 @@ function ui_print_help_icon ($help_id, $return = false, $home_url = '', $image =
if (empty($home_url))
$home_url = "";
if(defined('METACONSOLE')) {
if (defined('METACONSOLE')) {
$home_url = "../../" . $home_url;
}
@ -1855,7 +1855,7 @@ function ui_get_status_images_path () {
* @return string HTML code if return parameter is true.
*/
function ui_print_status_image ($type, $title = "", $return = false, $options = false, $path = false) {
if($path === false) {
if ($path === false) {
list ($imagepath) = ui_get_status_images_path ();
}
else {
@ -1864,7 +1864,7 @@ function ui_print_status_image ($type, $title = "", $return = false, $options =
$imagepath .= "/" . $type;
if($options === false) {
if ($options === false) {
$options = array();
}
@ -2184,7 +2184,7 @@ function ui_print_page_header ($title, $icon = "", $return = false, $help = "",
if (is_array($options)) {
$buffer .= '<div id="menu_tab"><ul class="mn">';
foreach ($options as $key => $option) {
if(empty($option)) {
if (empty($option)) {
continue;
}
else if ($key === 'separator') {
@ -3309,7 +3309,7 @@ function ui_get_error ($error_code) {
$message .= db_get_last_error();
$message .= '</span>';
if($error_code == 'error_authconfig') {
if ($error_code == 'error_authconfig') {
$message .= '<br/><br/>';
$message .= __('If you have modified auth system, this problem could be because Pandora cannot override authorization variables from the config database. Remove them from your database by executing:<br><pre>DELETE FROM tconfig WHERE token = "auth";</pre>');
}

View File

@ -13,40 +13,6 @@
$ttl = 1;
$homeurl = '';
/*function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) {
global $ttl;
global $homeurl;
$ttl = $serialize_ttl;
$homeurl = $home_url;
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
include_once($homeurl . 'include/graphs/functions_fsgraph.php');
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');
}*/
/*
// If is called from index
if(file_exists('include/functions.php')) {
include_once('include/functions.php');
include_once('include/graphs/functions_fsgraph.php');
include_once('include/graphs/functions_utils.php');
} // If is called through url
else if(file_exists('../functions.php')) {
include_once('../functions.php');
include_once('../functions_html.php');
include_once('functions_fsgraph.php');
include_once('functions_gd.php');
include_once('functions_utils.php');
}
include_once('functions_fsgraph.php');
include_once('functions_utils.php');
*/
if (isset($_GET['homeurl'])) {
$homeurl = $_GET['homeurl'];
}
@ -197,7 +163,7 @@ function vbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if($flash_chart) {
if ($flash_chart) {
return flot_vcolumn_chart ($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url, $homedir, $reduce_data_columns, $adapt_key);
}
else {
@ -285,7 +251,7 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color,
return '<img src="' . $no_data_image . '" />';
}
if($flash_chart) {
if ($flash_chart) {
return flot_area_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
}
else {
@ -321,7 +287,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color,
}
if($flash_chart) {
if ($flash_chart) {
return flot_line_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
}
else {
@ -356,7 +322,7 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend,
return '<img src="' . $no_data_image . '" />';
}
if($flash_chart) {
if ($flash_chart) {
return flot_line_simple_graph($chart_data, $width, $height, $color, $legend, $long_index, $homeurl, $unit, $water_mark_url);
}
else {
@ -407,7 +373,7 @@ function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array()
setup_watermark($water_mark, $water_mark_file, $water_mark_url);
if($flash_chart) {
if ($flash_chart) {
if ($return){
return flot_hcolumn_chart ($chart_data, $width, $height, $water_mark_url);
}

View File

@ -14,23 +14,23 @@
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
/* Function that includes all graph dependencies */
function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) {
global $config;
global $ttl;
global $homeurl;
/* Function that includes all graph dependencies */
function include_graphs_dependencies($home_url = '', $serialize_ttl = 1) {
global $config;
global $ttl;
global $homeurl;
$ttl = $serialize_ttl;
$homeurl = $home_url;
include_once($homeurl . 'include/functions_io.php');
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
$ttl = $serialize_ttl;
$homeurl = $home_url;
include_once($homeurl . 'include/functions_io.php');
include_once($homeurl . 'include/functions.php');
include_once($homeurl . 'include/functions_html.php');
if($config['flash_charts'] && !defined('AJAX') && !get_parameter('static_graph',0)) {
include_once($homeurl . 'include/graphs/functions_flot.php');
}
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');
if ($config['flash_charts'] && !defined('AJAX') && !get_parameter('static_graph',0)) {
include_once($homeurl . 'include/graphs/functions_flot.php');
}
include_once($homeurl . 'include/graphs/functions_gd.php');
include_once($homeurl . 'include/graphs/functions_utils.php');
}
?>

File diff suppressed because it is too large Load Diff

View File

@ -111,7 +111,7 @@
config.callbackPre ();
// Get the selected item from hidden field
selected = $('#hidden-'+config.moduleSelect.attr('id')+'_selected').val();
if(selected == i) {
if (selected == i) {
option = $("<option></option>")
.attr ("selected", "selected")
.attr ("value", value['id_agente_modulo'])

View File

@ -58,7 +58,7 @@ function js_html_entity_decode (str) {
*/
Array.prototype.in_array = function () {
for (var j in this) {
if(this[j] == arguments[0])
if (this[j] == arguments[0])
return true;
}
@ -794,5 +794,5 @@ function hidded_sidebar(position, menuW, menuH, icon_width, top_dist, autotop, r
// Function that recover a previously stored value from php code
function get_php_value(value) {
return $('#php_to_js_value_' + value).html();
return $.parseJSON($('#php_to_js_value_' + value).html());
}

View File

@ -2,7 +2,7 @@
function show_event_dialog(event_id, group_rep, dialog_page, result) {
var ajax_file = $('#hidden-ajax_file').val();
if(dialog_page == undefined) {
if (dialog_page == undefined) {
dialog_page = 'general';
}
@ -121,7 +121,7 @@ function execute_response(event_id, server_id) {
var response = get_response(response_id);
// If cannot get response abort it
if(response == null) {
if (response == null) {
return;
}
@ -132,7 +132,7 @@ function execute_response(event_id, server_id) {
show_response_dialog(event_id, response_id, response);
break;
case 'url':
if(response['new_window'] == 1) {
if (response['new_window'] == 1) {
window.open(response['target'],'_blank');
}
else {