From e46cfc566d7b2d69de3c19b93438cbeb5db77fdc Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Wed, 23 Mar 2011 12:15:53 +0000 Subject: [PATCH] 2011-03-23 Miguel de Dios * extensions/insert_data.php, extensions/system_info.php, extensions/agents_modules.php, extensions/ssh_console.php, extensions/resource_registration.php, extensions/resource_exportation.php, extensions/plugin_registration.php: re-ordered and re-cleaned some parts or lines of source code. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@4123 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 + pandora_console/extensions/agents_modules.php | 6 +- pandora_console/extensions/insert_data.php | 203 +++++++++--------- .../extensions/plugin_registration.php | 6 +- .../extensions/resource_exportation.php | 2 +- .../extensions/resource_registration.php | 4 +- pandora_console/extensions/ssh_console.php | 20 +- pandora_console/extensions/system_info.php | 45 ++-- 8 files changed, 142 insertions(+), 152 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index c8069d9d50..f7b667f548 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2011-03-23 Miguel de Dios + + * extensions/insert_data.php, extensions/system_info.php, + extensions/agents_modules.php, extensions/ssh_console.php, + extensions/resource_registration.php, extensions/resource_exportation.php, + extensions/plugin_registration.php: re-ordered and re-cleaned some parts or + lines of source code. + 2011-03-23 Miguel de Dios * include/functions_reporting.php: fixed the include "fgraph", did'nt show diff --git a/pandora_console/extensions/agents_modules.php b/pandora_console/extensions/agents_modules.php index 12b14081f9..2aff6abf57 100644 --- a/pandora_console/extensions/agents_modules.php +++ b/pandora_console/extensions/agents_modules.php @@ -167,15 +167,15 @@ function mainAgentsModules() { $nmodules = 0; foreach($modules_by_name as $module) { $nmodules++; - + if($nmodules <= $hor_offset || $nmodules > ($hor_offset+$block)) { continue; } - + $file_name = string2image(printTruncateText($module['name'],15, false, true, false, '...'), 115, 13, 3, 270, '#9EAC8B', 'FFF', 4, 0); echo ''.print_image($file_name, true, array('title' => $module['name'])).""; } - + if(($hor_offset + $block) < $nmodules) { $new_hor_offset = $hor_offset+$block; echo "".print_image("images/darrowright.png",true, array('title' => __('More modules')))." "; diff --git a/pandora_console/extensions/insert_data.php b/pandora_console/extensions/insert_data.php index ce49ead6c0..da31bc57ea 100644 --- a/pandora_console/extensions/insert_data.php +++ b/pandora_console/extensions/insert_data.php @@ -45,16 +45,14 @@ function createXMLData($agent, $agentModule, $time, $data) { function mainInsertData() { global $config; - print_page_header (__("Insert data"), "images/extensions.png", false, "", true, ""); - if (! check_acl ($config['id_user'], 0, "AW") && ! is_user_admin ($config['id_user'])) { pandora_audit("ACL Violation", "Trying to access Setup Management"); require ("general/noaccess.php"); return; } - + $save = (bool)get_parameter('save', false); $id_agent = (string)get_parameter('id_agent', ''); $id_agent_module = (int)get_parameter('id_agent_module', ''); @@ -78,39 +76,38 @@ function mainInsertData() { if (!check_acl($config['id_user'], get_agent_group(get_agent_id($id_agent)), "AW")) { print_error_message(__('You haven\'t privileges for insert data in the agent.')); } - else { - $agent = get_db_row_filter('tagente', array('nombre' => $id_agent)); - $agentModule = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $id_agent_module)); - - $date2 = str_replace('-', '/', $date); - $time2 = DATE("H:i", strtotime($time)); - - $date_xml = $date2 . ' ' . $time2 . ':00'; - - if ($csv !== false) { - $file = file($csv['tmp_name']); - foreach ($file as $line) { - $tokens = explode(';', $line); - createXMLData($agent, $agentModule, trim($tokens[0]), trim($tokens[1])); + else { + $agent = get_db_row_filter('tagente', array('nombre' => $id_agent)); + $agentModule = get_db_row_filter('tagente_modulo', array('id_agente_modulo' => $id_agent_module)); + + $date2 = str_replace('-', '/', $date); + $time2 = DATE("H:i", strtotime($time)); + + $date_xml = $date2 . ' ' . $time2 . ':00'; + + if ($csv !== false) { + $file = file($csv['tmp_name']); + foreach ($file as $line) { + $tokens = explode(';', $line); + + createXMLData($agent, $agentModule, trim($tokens[0]), trim($tokens[1])); + } + } + else { + createXMLData($agent, $agentModule, $date_xml, $data); } } - else { - createXMLData($agent, $agentModule, $date_xml, $data); - } } -} - - - + echo '
'; echo __("Please check that the directory \"/var/spool/pandora/data_in\" is writeable by the apache user.

The CSV file format is date;value<newline>date;value<newline>... The date in CSV is in format Y/m/d H:i:s."); echo '
'; - + $table = null; $table->width = '80%'; $table->style = array(); $table->style[0] = 'font-weight: bolder;'; - + $table->data = array(); $table->data[0][0] = __('Agent'); $table->data[0][1] = print_input_text_extended ('id_agent', $id_agent, 'text_id_agent', '', 30, 100, false, '', @@ -129,101 +126,101 @@ function mainInsertData() { $table->data[3][1] .= print_input_text ('time', $time, '', 7, 7, true); $table->data[4][0] = __('CSV'); $table->data[4][1] = print_input_file('csv', true); - + echo "
"; - + print_table($table); - + echo "
"; print_input_hidden('save', 1); print_submit_button(__('Save'), 'submit', ($id_agent === ''), 'class="sub next"'); echo "
"; - + echo "
"; - + require_css_file ('datepicker'); require_jquery_file ('ui.core'); require_jquery_file ('ui.datepicker'); require_jquery_file ('timeentry'); require_jquery_file ('autocomplete'); ?> - + + $("#text-time").timeEntry ({ + spinnerImage: 'images/time-entry.png', + spinnerSize: [20, 20, 0] + }); + + $("#text-date").datepicker (); + + }); + + $("#text_id_agent").result ( + function () { + selectAgent = true; + var agent_name = this.value; + $('#id_agent_module').fadeOut ('normal', function () { + $('#id_agent_module').empty (); + var inputs = []; + inputs.push ("agent_name=" + agent_name); + inputs.push ('filter=delete_pending = 0'); + inputs.push ("get_agent_modules_json=1"); + inputs.push ("page=operation/agentes/ver_agente"); + jQuery.ajax ({ + data: inputs.join ("&"), + type: 'GET', + url: action="ajax.php", + timeout: 10000, + dataType: 'json', + success: function (data) { + $('#id_agent_module').append ($('').attr ('value', 0).text ("--")); + jQuery.each (data, function (i, val) { + s = js_html_entity_decode (val['nombre']); + $('#id_agent_module').append ($('').attr ('value', val['id_agente_modulo']).text (s)); + }); + $('#id_agent_module').enable(); + $('#id_agent_module').fadeIn ('normal'); + + $('#submit-submit').enable(); + $('#submit-submit').fadeIn ('normal'); + } + }); + }); + + + } + ); + /* ]]> */ + +?> \ No newline at end of file diff --git a/pandora_console/extensions/plugin_registration.php b/pandora_console/extensions/plugin_registration.php index b355346dad..d88b4580a6 100644 --- a/pandora_console/extensions/plugin_registration.php +++ b/pandora_console/extensions/plugin_registration.php @@ -16,6 +16,7 @@ function pluginreg_extension_main () { global $config; + if (! check_acl ($config['id_user'], 0, "PM") && ! is_user_admin ($config['id_user'])) { pandora_audit("ACL Violation", "Trying to access Setup Management"); require ("general/noaccess.php"); @@ -47,9 +48,10 @@ function pluginreg_extension_main () { if ($zip) { while ($zip_entry = zip_read($zip)) { if (zip_entry_open($zip, $zip_entry, "r")) { - if (zip_entry_name($zip_entry) == "plugin_definition.ini"){ + if (zip_entry_name($zip_entry) == "plugin_definition.ini") { $basepath = $config["attachment_store"]; - } else { + } + else { $basepath = $config["plugin_store"]; } $filename = $basepath . "/". zip_entry_name($zip_entry); diff --git a/pandora_console/extensions/resource_exportation.php b/pandora_console/extensions/resource_exportation.php index 499d619b0c..e5b7990d01 100644 --- a/pandora_console/extensions/resource_exportation.php +++ b/pandora_console/extensions/resource_exportation.php @@ -372,4 +372,4 @@ function resource_exportation_extension_main() { +?> \ No newline at end of file diff --git a/pandora_console/extensions/resource_registration.php b/pandora_console/extensions/resource_registration.php index 5f66826b65..7059f7e236 100644 --- a/pandora_console/extensions/resource_registration.php +++ b/pandora_console/extensions/resource_registration.php @@ -815,7 +815,7 @@ function resource_registration_extension_main() { require_once($config['homedir'] . '/include/functions_network_components.php'); require_once($config['homedir'] . '/include/functions_db.php'); enterprise_include_once('include/functions_local_components.php'); - + print_page_header (__('Resource registration'), "images/extensions.png", false, "", true, "" ); if (!extension_loaded("libxml")) { @@ -860,4 +860,4 @@ function resource_registration_extension_main() { add_godmode_menu_option (__('Resource registration'), 'PM','gservers',''); add_extension_godmode_function('resource_registration_extension_main'); -?> +?> \ No newline at end of file diff --git a/pandora_console/extensions/ssh_console.php b/pandora_console/extensions/ssh_console.php index 1c233120e2..8f76c7cd7c 100644 --- a/pandora_console/extensions/ssh_console.php +++ b/pandora_console/extensions/ssh_console.php @@ -26,16 +26,16 @@ function main_ssh_console () { ?>
- - - - - - - - - - + + + + + + + + + +
'; echo __("This extension can run as PHP script in a shell for extract more information, but it must be run as root or across sudo. For example: sudo php /var/www/pandora_console/extensions/system_info.php -d -s -c"); echo ''; - + echo "

" . __('This tool is used just to view your Pandora FMS system logfiles directly from console') . "

"; echo "
"; @@ -284,20 +285,20 @@ function mainSystemInfo() { print_submit_button(__('Generate file'), 'generate', false, 'class="sub next"'); echo ""; echo "
"; - + if ($show) { if ($pandora_diag) { $info = array(); getPandoraDiagnostic($info); show_array(__('Pandora Diagnostic info'), 'diag_info', $info); } - + if ($system_info) { $info = array(); getSystemInfo($info); show_array(__('System info'), 'system_info', $info); } - + if ($log_info) { echo "

" . __('Log Info') . "

"; getLastLog($log_num_lines); @@ -309,10 +310,9 @@ function mainSystemInfo() { $tempDir = $tempDirSystem . '/' . $nameDir . '/'; mkdir($tempDir); - $zipArchive = $config['attachment_store'] . '/last_info.zip'; @unlink($zipArchive); - + if ($config['https']) { $http = 'https://'; } @@ -322,7 +322,7 @@ function mainSystemInfo() { $url = '' . __('System info file zipped') . ''; echo '' . __('File:') . ' ' . $url; - + $zip = new ZipArchive; if ($zip->open($zipArchive, ZIPARCHIVE::CREATE) === true) { @@ -355,7 +355,7 @@ function mainSystemInfo() { if ($system_info) { $info = array(); getSystemInfo($info); - + $file = fopen($tempDir . 'system_info.txt', 'w'); if ($file !== false) { @@ -377,7 +377,7 @@ function mainSystemInfo() { $zip->addFile($tempDir . 'system_info.txt', 'system_info.txt'); } - + if ($log_info) { file_put_contents($tempDir . 'pandora_console.log.lines_' . $log_num_lines, getLastLinesLog($config["homedir"]."/pandora_console.log", $log_num_lines)); $zip->addFile($tempDir . 'pandora_console.log.lines_' . $log_num_lines, 'pandora_console.log.lines_' . $log_num_lines); @@ -394,26 +394,9 @@ function mainSystemInfo() { file_put_contents($tempDir . 'syslog.lines_' . $log_num_lines, getLastLinesLog("/var/log/syslog", $log_num_lines)); $zip->addFile($tempDir . 'syslog.lines_' . $log_num_lines, 'syslog.lines_' . $log_num_lines); } - + $zip->close(); } -// -// if ($pandora_diag) { -// $info = array(); -// getPandoraDiagnostic($info); -// show_array(__('Pandora Diagnostic info'), 'diag_info', $info); -// } -// -// if ($system_info) { -// $info = array(); -// getSystemInfo($info); -// show_array(__('System info'), 'system_info', $info); -// } -// -// if ($log_info) { -// echo "

" . __('Log Info') . "

"; -// getLastLog($log_num_lines); -// } } } @@ -630,4 +613,4 @@ else { consoleMode(); } -?> +?> \ No newline at end of file