2012-07-10 Miguel de Dios <miguel.dedios@artica.es>

* extensions/agents_alerts.php, extensions/net_tools.php,
	extensions/ssh_gateway.php,
	extensions/update_manager/lib/libupdate_manager_components.php,
	extensions/update_manager/lib/libupdate_manager_updates.php,
	general/main_menu.php: cleaned source code style and added into some
	strings the call to translation.




git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@6758 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
mdtrooper 2012-07-10 09:21:19 +00:00
parent f5ac7cc261
commit ae4a12872c
7 changed files with 188 additions and 185 deletions

View File

@ -1,3 +1,12 @@
2012-07-10 Miguel de Dios <miguel.dedios@artica.es>
* extensions/agents_alerts.php, extensions/net_tools.php,
extensions/ssh_gateway.php,
extensions/update_manager/lib/libupdate_manager_components.php,
extensions/update_manager/lib/libupdate_manager_updates.php,
general/main_menu.php: cleaned source code style and added into some
strings the call to translation.
2012-07-09 Sergio Martin <sergio.martin@artica.es> 2012-07-09 Sergio Martin <sergio.martin@artica.es>
* operation/extensions.php * operation/extensions.php

View File

@ -287,10 +287,12 @@ function print_alerts_summary_modal_window($id, $alerts) {
if ($alert["times_fired"] > 0) { if ($alert["times_fired"] > 0) {
$status = STATUS_ALERT_FIRED; $status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times'); $title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
} elseif ($alert["disabled"] > 0) { }
elseif ($alert["disabled"] > 0) {
$status = STATUS_ALERT_DISABLED; $status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled'); $title = __('Alert disabled');
} else { }
else {
$status = STATUS_ALERT_NOT_FIRED; $status = STATUS_ALERT_NOT_FIRED;
$title = __('Alert not fired'); $title = __('Alert not fired');
} }
@ -301,7 +303,7 @@ function print_alerts_summary_modal_window($id, $alerts) {
} }
$content = html_print_table($table,true); $content = html_print_table($table,true);
$agent = modules_get_agentmodule_agent_name($alerts[0]['id_agent_module']); $agent = modules_get_agentmodule_agent_name($alerts[0]['id_agent_module']);
$template = alerts_get_alert_template_name($alerts[0]['id_alert_template']); $template = alerts_get_alert_template_name($alerts[0]['id_alert_template']);
@ -317,7 +319,6 @@ ui_require_jquery_file('pandora');
<script type="text/javascript"> <script type="text/javascript">
function show_alerts_details(id) { function show_alerts_details(id) {
$("#alerts_details_"+id).dialog({ $("#alerts_details_"+id).dialog({
resizable: true, resizable: true,
draggable: true, draggable: true,
@ -325,9 +326,9 @@ ui_require_jquery_file('pandora');
height: 280, height: 280,
width: 800, width: 800,
overlay: { overlay: {
opacity: 0.5, opacity: 0.5,
background: "black" background: "black"
}, },
bgiframe: jQuery.browser.msie bgiframe: jQuery.browser.msie
}); });
} }

View File

@ -17,29 +17,29 @@
extensions_add_opemode_tab_agent ('network_tools','Network Tools','extensions/net_tools/nettool.png',"main_net_tools"); extensions_add_opemode_tab_agent ('network_tools','Network Tools','extensions/net_tools/nettool.png',"main_net_tools");
function whereis_the_command ($command) { function whereis_the_command ($command) {
ob_start(); ob_start();
system('whereis '. $command); system('whereis '. $command);
$output = ob_get_clean(); $output = ob_get_clean();
$result = explode(':', $output); $result = explode(':', $output);
$result = trim($result[1]); $result = trim($result[1]);
if ( empty($result)) { if ( empty($result)) {
return NULL; return NULL;
} }
$result = explode(' ', $result); $result = explode(' ', $result);
$fullpath = trim($result[0]); $fullpath = trim($result[0]);
if (! file_exists($fullpath)) { if (! file_exists($fullpath)) {
return NULL; return NULL;
} }
return $fullpath; return $fullpath;
} }
function main_net_tools () { function main_net_tools () {
$id_agente = get_parameter ("id_agente"); $id_agente = get_parameter ("id_agente");
$ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); $ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
if ($ip == "") { if ($ip == "") {
@ -67,13 +67,13 @@ function main_net_tools () {
echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>"; echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>";
echo "</tr></table>"; echo "</tr></table>";
echo "</form>"; echo "</form>";
$operation = get_parameter ("operation",0); $operation = get_parameter ("operation",0);
$community = get_parameter ("community","public"); $community = get_parameter ("community","public");
switch($operation) { switch($operation) {
case 1: case 1:
$traceroute = whereis_the_command ('traceroute'); $traceroute = whereis_the_command ('traceroute');
if (empty($traceroute)) { if (empty($traceroute)) {
ui_print_error_message(__('Traceroute executable does not exist.')); ui_print_error_message(__('Traceroute executable does not exist.'));
@ -84,95 +84,89 @@ function main_net_tools () {
echo system ("$traceroute $ip"); echo system ("$traceroute $ip");
echo "</pre>"; echo "</pre>";
} }
break;
break; case 2:
case 2:
$ping = whereis_the_command ('ping'); $ping = whereis_the_command ('ping');
if (empty($ping)) { if (empty($ping)) {
ui_print_error_message(__('Ping executable does not exist.')); ui_print_error_message(__('Ping executable does not exist.'));
} }
else { else {
echo "<h3>".__("Ping to "). $ip. "</h3>"; echo "<h3>".__("Ping to "). $ip. "</h3>";
echo "<pre>"; echo "<pre>";
echo system ("$ping -c 5 $ip"); echo system ("$ping -c 5 $ip");
echo "</pre>"; echo "</pre>";
} }
break; break;
case 4:
case 4:
$nmap = whereis_the_command ('nmap'); $nmap = whereis_the_command ('nmap');
if (empty($nmap)) { if (empty($nmap)) {
ui_print_error_message(__('Nmap executable does not exist.')); ui_print_error_message(__('Nmap executable does not exist.'));
} }
else { else {
echo "<h3>".__("Basic TCP Scan on "). $ip. "</h3>"; echo "<h3>".__("Basic TCP Scan on "). $ip. "</h3>";
echo "<pre>"; echo "<pre>";
echo system ("$nmap -F $ip"); echo system ("$nmap -F $ip");
echo "</pre>"; echo "</pre>";
} }
break; break;
case 5:
case 5: echo "<h3>".__("Domain and IP information for "). $ip. "</h3>";
echo "<h3>".__("Domain and IP information for "). $ip. "</h3>";
$dig = whereis_the_command ('dig'); $dig = whereis_the_command ('dig');
if (empty($dig)) { if (empty($dig)) {
ui_print_error_message(__('Dig executable does not exist.')); ui_print_error_message(__('Dig executable does not exist.'));
} }
else { else {
echo "<pre>"; echo "<pre>";
echo system ("dig $ip"); echo system ("dig $ip");
echo "</pre>"; echo "</pre>";
} }
$whois = whereis_the_command ('whois'); $whois = whereis_the_command ('whois');
if (empty($whois)) { if (empty($whois)) {
ui_print_error_message(__('Whois executable does not exist.')); ui_print_error_message(__('Whois executable does not exist.'));
} }
else { else {
echo "<pre>"; echo "<pre>";
echo system ("whois $ip"); echo system ("whois $ip");
echo "</pre>"; echo "</pre>";
} }
break; break;
case 3:
case 3:
echo "<h3>".__("SNMP information for "). $ip. "</h3>"; echo "<h3>".__("SNMP information for "). $ip. "</h3>";
$snmpget = whereis_the_command ('snmpget'); $snmpget = whereis_the_command ('snmpget');
if (empty($snmpget)) { if (empty($snmpget)) {
ui_print_error_message(__('SNMPget executable does not exist.')); ui_print_error_message(__('SNMPget executable does not exist.'));
} }
else { else {
echo "<h4>Uptime</h4>"; echo "<h4>" . __("Uptime") . "</h4>";
echo "<pre>"; echo "<pre>";
echo exec ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 "); echo exec ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
echo "</pre>"; echo "</pre>";
echo "<h4>Device info</h4>"; echo "<h4>" . __("Device info") . "</h4>";
echo "<pre>"; echo "<pre>";
echo system ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.1.0 ");
echo "</pre>";
echo "<h4>Interface Information</h4>";
echo "<table class=databox>";
echo "<tr><th>".__("Interface");
echo "<th>".__("Status");
$int_max = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.1.0 ");
for ($ax=0; $ax < $int_max; $ax++){
$interface = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.2.$ax ");
$estado = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.8.$ax ");
echo "<tr><td>$interface<td>$estado";
}
echo "</table>";
}
break;
}
echo system ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.1.0 "); echo "</div>";
echo "</pre>";
echo "<h4>Interface Information</h4>";
echo "<table class=databox>";
echo "<tr><th>".__("Interface");
echo "<th>".__("Status");
$int_max = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.1.0 ");
for ($ax=0; $ax < $int_max; $ax++){
$interface = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.2.$ax ");
$estado = exec ("$snmpget -Oqunv -v1 -c $community $ip .1.3.6.1.2.1.2.2.1.8.$ax ");
echo "<tr><td>$interface<td>$estado";
}
echo "</table>";
}
break;
}
echo "</div>";
} }
?>
?>

View File

@ -17,34 +17,32 @@
extensions_add_opemode_tab_agent ('ssh_gateway','SSH Gateway','extensions/ssh_gateway/secure_console.png',"ssh_gateway"); extensions_add_opemode_tab_agent ('ssh_gateway','SSH Gateway','extensions/ssh_gateway/secure_console.png',"ssh_gateway");
function ssh_gateway () { function ssh_gateway () {
$SERVER_ADDR = $_SERVER['SERVER_ADDR']; $SERVER_ADDR = $_SERVER['SERVER_ADDR'];
$HOST = get_parameter ("host", ""); $HOST = get_parameter ("host", "");
$USER = get_parameter ("user", ""); $USER = get_parameter ("user", "");
// TODO: Put aditional filtering for ";" and "&" characters in user & host for security // TODO: Put aditional filtering for ";" and "&" characters in user & host for security
// because these params are passed to server exec() call :) // because these params are passed to server exec() call :)
$COMMIT = get_parameter ("commit", 0); $COMMIT = get_parameter ("commit", 0);
$MODE = get_parameter ("mode", "ssh"); $MODE = get_parameter ("mode", "ssh");
if ($MODE == "telnet") if ($MODE == "telnet")
$USER = "<auto>"; $USER = "<auto>";
$id_agente = get_parameter ("id_agente"); $id_agente = get_parameter ("id_agente");
$ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente"); $ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
if ($HOST == "") if ($HOST == "")
$HOST = $ip; $HOST = $ip;
if (($HOST == "") OR ($USER == "")){ if (($HOST == "") OR ($USER == "")) {
if ($COMMIT == 1) {
if ($COMMIT == 1){
echo "<h3 class=error>".__("You need to specify a user and a host address")."</h3>"; echo "<h3 class=error>".__("You need to specify a user and a host address")."</h3>";
} }
echo "<form method=post>"; echo "<form method=post>";
echo "<table class=databox cellspacing=4 cellpadding=4>"; echo "<table class=databox cellspacing=4 cellpadding=4>";
echo "<td>".__("Host address")."<td><input type=text size=25 value='$HOST' name=host>"; echo "<td>".__("Host address")."<td><input type=text size=25 value='$HOST' name=host>";
@ -52,29 +50,28 @@ function ssh_gateway () {
echo "<td>".__("User")."<td><input type=text size=25 value='$USER' name=user>"; echo "<td>".__("User")."<td><input type=text size=25 value='$USER' name=user>";
echo "<tr><td>"; echo "<tr><td>";
echo __("Connect mode")."<td><select name=mode>"; echo __("Connect mode")."<td><select name=mode>";
if ($MODE == "telnet"){ if ($MODE == "telnet") {
echo "<option>telnet"; echo "<option>telnet";
echo "<option>ssh"; echo "<option>ssh";
} else { }
else {
echo "<option>ssh"; echo "<option>ssh";
echo "<option>telnet"; echo "<option>telnet";
} }
echo "</select>"; echo "</select>";
echo "&nbsp;&nbsp;&nbsp;<input type=submit name=connect class='sub upd' value=".__("Connect").">"; echo "&nbsp;&nbsp;&nbsp;<input type=submit name=connect class='sub upd' value=".__("Connect").">";
echo "<td><input type=hidden name=commit value=1>"; echo "<td><input type=hidden name=commit value=1>";
echo "</form></table>"; echo "</form></table>";
} }
else { else {
if ($MODE == "ssh") if ($MODE == "ssh")
echo "<iframe style='border: 0px' src='http://".$SERVER_ADDR.":8022/anyterm.html?param=$USER@$HOST' width='100%' height=550>"; echo "<iframe style='border: 0px' src='http://".$SERVER_ADDR.":8022/anyterm.html?param=$USER@$HOST' width='100%' height=550>";
else else
echo "<iframe style='border: 0px' src='http://".$SERVER_ADDR.":8023/anyterm.html?param=$HOST' width='100%' height=550>"; echo "<iframe style='border: 0px' src='http://".$SERVER_ADDR.":8023/anyterm.html?param=$HOST' width='100%' height=550>";
echo "</iframe>"; echo "</iframe>";
} }
} }
?>
?>

View File

@ -83,7 +83,7 @@ function um_component_database_get_all_tables () {
if ($config["dbtype"] == 'oracle') { if ($config["dbtype"] == 'oracle') {
$tables[] = $table['table_name']; $tables[] = $table['table_name'];
} }
else { else {
$tables[] = $table[0]; $tables[] = $table[0];
} }
} }
@ -106,11 +106,11 @@ function um_component_database_get_table_fields ($table_name) {
global $config; global $config;
$db = um_component_db_connect (); $db = um_component_db_connect ();
if ($db === false) { if ($db === false) {
return array (); return array ();
} }
switch ($config["dbtype"]) { switch ($config["dbtype"]) {
case "mysql": case "mysql":
$result = db_process_sql('SHOW COLUMNS FROM '.$table_name.' WHERE `Key` != "PRI"'); $result = db_process_sql('SHOW COLUMNS FROM '.$table_name.' WHERE `Key` != "PRI"');
@ -121,18 +121,18 @@ function um_component_database_get_table_fields ($table_name) {
break; break;
case "oracle": case "oracle":
$result = db_process_sql("SELECT cols1.column_name as Fields, cols1.data_type as Type, $result = db_process_sql("SELECT cols1.column_name as Fields, cols1.data_type as Type,
CASE WHEN (cols1.nullable = 'Y') THEN 'YES' ELSE 'NO' END as \"Null\", CASE WHEN (cols1.nullable = 'Y') THEN 'YES' ELSE 'NO' END as \"Null\",
cols1.data_default as \"Default\", '' as Extra cols1.data_default as \"Default\", '' as Extra
FROM user_tab_columns cols1 FROM user_tab_columns cols1
WHERE cols1.table_name ='".$table_name."' WHERE cols1.table_name ='".$table_name."'
AND cols1.column_name NOT IN (select distinct usr.column_name AND cols1.column_name NOT IN (select distinct usr.column_name
from user_cons_columns usr, user_constraints co from user_cons_columns usr, user_constraints co
where usr.constraint_name = co.constraint_name and where usr.constraint_name = co.constraint_name and
constraint_type = 'P' and co.table_name = '" . $table_name . "') constraint_type = 'P' and co.table_name = '" . $table_name . "')
order by cols1.column_id"); order by cols1.column_id");
break; break;
} }
if ($result === false) { if ($result === false) {
echo '<strong>Error getting table fields</strong> <br />'; echo '<strong>Error getting table fields</strong> <br />';
return array(); return array();
@ -223,7 +223,7 @@ function um_component_get_all_blacklisted ($component) {
WHERE component = \''.$component->name.'\''); WHERE component = \''.$component->name.'\'');
break; break;
} }
$cont = 0; $cont = 0;
$list = array(); $list = array();
while(true) { while(true) {
@ -259,14 +259,14 @@ function um_component_is_blacklisted ($component, $name) {
} }
$retval = um_std_from_result($result); $retval = um_std_from_result($result);
return $retval->blacklisted ? true : false; return $retval->blacklisted ? true : false;
} }
function um_component_add_blacklist ($component, $name) { function um_component_add_blacklist ($component, $name) {
$values = array('component' => $component->name, 'name' => $name); $values = array('component' => $component->name, 'name' => $name);
$result = db_process_sql_insert(DB_PREFIX.'tupdate_component_blacklist', $values); $result = db_process_sql_insert(DB_PREFIX.'tupdate_component_blacklist', $values);
if ($result === false) { if ($result === false) {
echo '<strong>Error creating blacklist component</strong> <br />'; echo '<strong>Error creating blacklist component</strong> <br />';
return false; return false;

View File

@ -144,57 +144,58 @@ function um_db_create_update ($type, $component_name, $id_package, $update, $db_
'component' => $component_name, 'component' => $component_name,
'id_update_package' => $id_package); 'id_update_package' => $id_package);
switch ($type) { switch ($type) {
case 'code': case 'code':
$filepath = realpath ($component->path.'/'.$update->filename); $filepath = realpath ($component->path.'/'.$update->filename);
$values['svn_version'] = um_file_get_svn_revision ($filepath); $values['svn_version'] = um_file_get_svn_revision ($filepath);
case 'binary': case 'binary':
$last_update = um_update_get_last_from_filename ($component_name, $update->filename); $last_update = um_update_get_last_from_filename ($component_name, $update->filename);
$filepath = realpath ($component->path.'/'.$update->filename); $filepath = realpath ($component->path.'/'.$update->filename);
$values['checksum'] = md5_file ($filepath); $values['checksum'] = md5_file ($filepath);
if ($last_update && $last_update->checksum == $values['checksum']) { if ($last_update && $last_update->checksum == $values['checksum']) {
return false;
}
/* Add relative path if has one */
if ($component->relative_path != '') {
$values['filename'] = $component->relative_path.$update->filename;
}
else {
$values['filename'] = $update->filename;
}
$values['data'] = um_file_uuencode ($filepath);
if ($last_update && $last_update->checksum != '')
$values['previous_checksum'] = $last_update->checksum;
break;
case 'db_data':
if ($db_data === NULL)
return false;
$component_db = um_db_get_component_db ($update->id_component_db);
$field = $component_db->field_name;
$values['db_field_value'] = $db_data->$field;
$values['id_component_db'] = $update->id_component_db;
switch ($config["dbtype"]) {
case "mysql":
$values['data'] = um_data_encode('INSERT INTO `'.$component_db->table_name.'` (`'.implode('`,`', array_keys (get_object_vars ($db_data))).'`) VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
case "postgresql":
$values['data'] = um_data_encode('INSERT INTO "'.$component_db->table_name.'" ("'.implode('", "', array_keys (get_object_vars ($db_data))).'") VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
case "oracle":
$values['data'] = um_data_encode('INSERT INTO '.$component_db->table_name.' ('.implode(', ', array_keys (get_object_vars ($db_data))).') VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
}
break;
case 'db_schema':
$values['data'] = um_data_encode($update->data);
break;
default:
return false; return false;
} break;
/* Add relative path if has one */
if ($component->relative_path != '') {
$values['filename'] = $component->relative_path.$update->filename;
} else {
$values['filename'] = $update->filename;
}
$values['data'] = um_file_uuencode ($filepath);
if ($last_update && $last_update->checksum != '')
$values['previous_checksum'] = $last_update->checksum;
break;
case 'db_data':
if ($db_data === NULL)
return false;
$component_db = um_db_get_component_db ($update->id_component_db);
$field = $component_db->field_name;
$values['db_field_value'] = $db_data->$field;
$values['id_component_db'] = $update->id_component_db;
switch ($config["dbtype"]) {
case "mysql":
$values['data'] = um_data_encode('INSERT INTO `'.$component_db->table_name.'` (`'.implode('`,`', array_keys (get_object_vars ($db_data))).'`) VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
case "postgresql":
$values['data'] = um_data_encode('INSERT INTO "'.$component_db->table_name.'" ("'.implode('", "', array_keys (get_object_vars ($db_data))).'") VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
case "oracle":
$values['data'] = um_data_encode('INSERT INTO '.$component_db->table_name.' ('.implode(', ', array_keys (get_object_vars ($db_data))).') VALUES (\''.implode('\',\'', get_object_vars ($db_data)).'\')');
break;
}
break;
case 'db_schema':
$values['data'] = um_data_encode($update->data);
break;
default:
return false;
} }
$result = db_process_sql_insert(DB_PREFIX.'tupdate', $values); $result = db_process_sql_insert(DB_PREFIX.'tupdate', $values);
if ($result === false) { if ($result === false) {
echo '<strong>Error creating update</strong> <br />'; echo '<strong>Error creating update</strong> <br />';
return false; return false;

View File

@ -25,13 +25,14 @@ require ("operation/menu.php");
//Check all enterprise ACL used in godmenu items to print menu headers //Check all enterprise ACL used in godmenu items to print menu headers
if (check_acl ($config['id_user'], 0, "AW") || if (check_acl ($config['id_user'], 0, "AW") ||
check_acl ($config['id_user'], 0, "PM") || check_acl ($config['id_user'], 0, "PM") ||
check_acl ($config['id_user'], 0, "LM") || check_acl ($config['id_user'], 0, "LM") ||
check_acl ($config['id_user'], 0, "UM") || check_acl ($config['id_user'], 0, "UM") ||
check_acl ($config['id_user'], 0, "LW") || check_acl ($config['id_user'], 0, "LW") ||
check_acl ($config['id_user'], 0, "IW") || check_acl ($config['id_user'], 0, "IW") ||
check_acl ($config['id_user'], 0, "DW")) { check_acl ($config['id_user'], 0, "DW")) {
echo '<div class="tit bg3">:: '.__('Administration').' ::</div>';
echo '<div class="tit bg3">:: '.__('Administration').' ::</div>';
} }
require ("godmode/menu.php"); require ("godmode/menu.php");
@ -50,4 +51,4 @@ $(document).ready( function() {
}); });
}); });
/* ]]> */ /* ]]> */
</script> </script>