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>
* operation/extensions.php

View File

@ -287,10 +287,12 @@ function print_alerts_summary_modal_window($id, $alerts) {
if ($alert["times_fired"] > 0) {
$status = STATUS_ALERT_FIRED;
$title = __('Alert fired').' '.$alert["times_fired"].' '.__('times');
} elseif ($alert["disabled"] > 0) {
}
elseif ($alert["disabled"] > 0) {
$status = STATUS_ALERT_DISABLED;
$title = __('Alert disabled');
} else {
}
else {
$status = STATUS_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);
$agent = modules_get_agentmodule_agent_name($alerts[0]['id_agent_module']);
$template = alerts_get_alert_template_name($alerts[0]['id_alert_template']);
@ -317,7 +319,6 @@ ui_require_jquery_file('pandora');
<script type="text/javascript">
function show_alerts_details(id) {
$("#alerts_details_"+id).dialog({
resizable: true,
draggable: true,
@ -325,9 +326,9 @@ ui_require_jquery_file('pandora');
height: 280,
width: 800,
overlay: {
opacity: 0.5,
background: "black"
},
opacity: 0.5,
background: "black"
},
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");
function whereis_the_command ($command) {
ob_start();
system('whereis '. $command);
$output = ob_get_clean();
$result = explode(':', $output);
$result = trim($result[1]);
if ( empty($result)) {
return NULL;
}
$result = explode(' ', $result);
$fullpath = trim($result[0]);
if (! file_exists($fullpath)) {
return NULL;
}
return $fullpath;
}
function main_net_tools () {
$id_agente = get_parameter ("id_agente");
$ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
if ($ip == "") {
@ -67,13 +67,13 @@ function main_net_tools () {
echo "<input name=submit type=submit class='sub next' value='".__('Execute')."'>";
echo "</tr></table>";
echo "</form>";
$operation = get_parameter ("operation",0);
$community = get_parameter ("community","public");
switch($operation) {
case 1:
case 1:
$traceroute = whereis_the_command ('traceroute');
if (empty($traceroute)) {
ui_print_error_message(__('Traceroute executable does not exist.'));
@ -84,95 +84,89 @@ function main_net_tools () {
echo system ("$traceroute $ip");
echo "</pre>";
}
break;
case 2:
break;
case 2:
$ping = whereis_the_command ('ping');
if (empty($ping)) {
ui_print_error_message(__('Ping executable does not exist.'));
}
else {
echo "<h3>".__("Ping to "). $ip. "</h3>";
ui_print_error_message(__('Ping executable does not exist.'));
}
else {
echo "<h3>".__("Ping to "). $ip. "</h3>";
echo "<pre>";
echo system ("$ping -c 5 $ip");
echo "</pre>";
}
break;
case 4:
}
break;
case 4:
$nmap = whereis_the_command ('nmap');
if (empty($nmap)) {
ui_print_error_message(__('Nmap executable does not exist.'));
}
else {
echo "<h3>".__("Basic TCP Scan on "). $ip. "</h3>";
echo "<pre>";
echo system ("$nmap -F $ip");
echo "</pre>";
}
break;
case 5:
echo "<h3>".__("Domain and IP information for "). $ip. "</h3>";
ui_print_error_message(__('Nmap executable does not exist.'));
}
else {
echo "<h3>".__("Basic TCP Scan on "). $ip. "</h3>";
echo "<pre>";
echo system ("$nmap -F $ip");
echo "</pre>";
}
break;
case 5:
echo "<h3>".__("Domain and IP information for "). $ip. "</h3>";
$dig = whereis_the_command ('dig');
if (empty($dig)) {
ui_print_error_message(__('Dig executable does not exist.'));
}
else {
echo "<pre>";
ui_print_error_message(__('Dig executable does not exist.'));
}
else {
echo "<pre>";
echo system ("dig $ip");
echo "</pre>";
}
}
$whois = whereis_the_command ('whois');
if (empty($whois)) {
ui_print_error_message(__('Whois executable does not exist.'));
}
else {
echo "<pre>";
ui_print_error_message(__('Whois executable does not exist.'));
}
else {
echo "<pre>";
echo system ("whois $ip");
echo "</pre>";
}
break;
case 3:
}
break;
case 3:
echo "<h3>".__("SNMP information for "). $ip. "</h3>";
$snmpget = whereis_the_command ('snmpget');
if (empty($snmpget)) {
ui_print_error_message(__('SNMPget executable does not exist.'));
}
else {
echo "<h4>Uptime</h4>";
echo "<pre>";
echo exec ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
echo "</pre>";
echo "<h4>Device info</h4>";
echo "<pre>";
ui_print_error_message(__('SNMPget executable does not exist.'));
}
else {
echo "<h4>" . __("Uptime") . "</h4>";
echo "<pre>";
echo exec ("$snmpget -Ounv -v1 -c $community $ip .1.3.6.1.2.1.1.3.0 ");
echo "</pre>";
echo "<h4>" . __("Device info") . "</h4>";
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 "</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>";
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");
function ssh_gateway () {
$SERVER_ADDR = $_SERVER['SERVER_ADDR'];
$HOST = get_parameter ("host", "");
$USER = get_parameter ("user", "");
// TODO: Put aditional filtering for ";" and "&" characters in user & host for security
// because these params are passed to server exec() call :)
$COMMIT = get_parameter ("commit", 0);
$MODE = get_parameter ("mode", "ssh");
if ($MODE == "telnet")
$USER = "<auto>";
$id_agente = get_parameter ("id_agente");
$ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
if ($HOST == "")
$ip = db_get_sql ("SELECT direccion FROM tagente WHERE id_agente = $id_agente");
if ($HOST == "")
$HOST = $ip;
if (($HOST == "") OR ($USER == "")){
if ($COMMIT == 1){
if (($HOST == "") OR ($USER == "")) {
if ($COMMIT == 1) {
echo "<h3 class=error>".__("You need to specify a user and a host address")."</h3>";
}
echo "<form method=post>";
echo "<table class=databox cellspacing=4 cellpadding=4>";
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 "<tr><td>";
echo __("Connect mode")."<td><select name=mode>";
if ($MODE == "telnet"){
if ($MODE == "telnet") {
echo "<option>telnet";
echo "<option>ssh";
} else {
}
else {
echo "<option>ssh";
echo "<option>telnet";
}
}
echo "</select>";
echo "&nbsp;&nbsp;&nbsp;<input type=submit name=connect class='sub upd' value=".__("Connect").">";
echo "<td><input type=hidden name=commit value=1>";
echo "</form></table>";
}
else {
if ($MODE == "ssh")
echo "<iframe style='border: 0px' src='http://".$SERVER_ADDR.":8022/anyterm.html?param=$USER@$HOST' width='100%' height=550>";
else
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') {
$tables[] = $table['table_name'];
}
else {
else {
$tables[] = $table[0];
}
}
@ -106,11 +106,11 @@ function um_component_database_get_table_fields ($table_name) {
global $config;
$db = um_component_db_connect ();
if ($db === false) {
return array ();
}
switch ($config["dbtype"]) {
case "mysql":
$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;
case "oracle":
$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\",
cols1.data_default as \"Default\", '' as Extra
FROM user_tab_columns cols1
WHERE cols1.table_name ='".$table_name."'
AND cols1.column_name NOT IN (select distinct usr.column_name
from user_cons_columns usr, user_constraints co
where usr.constraint_name = co.constraint_name and
constraint_type = 'P' and co.table_name = '" . $table_name . "')
order by cols1.column_id");
CASE WHEN (cols1.nullable = 'Y') THEN 'YES' ELSE 'NO' END as \"Null\",
cols1.data_default as \"Default\", '' as Extra
FROM user_tab_columns cols1
WHERE cols1.table_name ='".$table_name."'
AND cols1.column_name NOT IN (select distinct usr.column_name
from user_cons_columns usr, user_constraints co
where usr.constraint_name = co.constraint_name and
constraint_type = 'P' and co.table_name = '" . $table_name . "')
order by cols1.column_id");
break;
}
if ($result === false) {
echo '<strong>Error getting table fields</strong> <br />';
return array();
@ -223,7 +223,7 @@ function um_component_get_all_blacklisted ($component) {
WHERE component = \''.$component->name.'\'');
break;
}
$cont = 0;
$list = array();
while(true) {
@ -259,14 +259,14 @@ function um_component_is_blacklisted ($component, $name) {
}
$retval = um_std_from_result($result);
return $retval->blacklisted ? true : false;
}
function um_component_add_blacklist ($component, $name) {
$values = array('component' => $component->name, 'name' => $name);
$result = db_process_sql_insert(DB_PREFIX.'tupdate_component_blacklist', $values);
if ($result === false) {
echo '<strong>Error creating blacklist component</strong> <br />';
return false;

View File

@ -144,57 +144,58 @@ function um_db_create_update ($type, $component_name, $id_package, $update, $db_
'component' => $component_name,
'id_update_package' => $id_package);
switch ($type) {
case 'code':
$filepath = realpath ($component->path.'/'.$update->filename);
$values['svn_version'] = um_file_get_svn_revision ($filepath);
case 'binary':
$last_update = um_update_get_last_from_filename ($component_name, $update->filename);
$filepath = realpath ($component->path.'/'.$update->filename);
$values['checksum'] = md5_file ($filepath);
if ($last_update && $last_update->checksum == $values['checksum']) {
case 'code':
$filepath = realpath ($component->path.'/'.$update->filename);
$values['svn_version'] = um_file_get_svn_revision ($filepath);
case 'binary':
$last_update = um_update_get_last_from_filename ($component_name, $update->filename);
$filepath = realpath ($component->path.'/'.$update->filename);
$values['checksum'] = md5_file ($filepath);
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;
}
/* 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;
break;
}
$result = db_process_sql_insert(DB_PREFIX.'tupdate', $values);
if ($result === false) {
echo '<strong>Error creating update</strong> <br />';
return false;

View File

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