2013-05-21 Miguel de Dios <miguel.dedios@artica.es>
* include/functions_reporting.php, include/functions.php: improved the source code style. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8180 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
ac4d5799d8
commit
3ed70944e4
|
@ -1,3 +1,8 @@
|
||||||
|
2013-05-21 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
|
* include/functions_reporting.php, include/functions.php: improved
|
||||||
|
the source code style.
|
||||||
|
|
||||||
2013-05-21 Miguel de Dios <miguel.dedios@artica.es>
|
2013-05-21 Miguel de Dios <miguel.dedios@artica.es>
|
||||||
|
|
||||||
* include/functions_modules.php: fixed false error when update the
|
* include/functions_modules.php: fixed false error when update the
|
||||||
|
|
|
@ -326,7 +326,7 @@ function human_time_comparation ($timestamp, $units = 'large') {
|
||||||
// $seconds could be negative, because get_system_time() could return cached value
|
// $seconds could be negative, because get_system_time() could return cached value
|
||||||
// (that might be the time a session begins at).
|
// (that might be the time a session begins at).
|
||||||
// So negative values are to be rounded off to 'NOW'.
|
// So negative values are to be rounded off to 'NOW'.
|
||||||
if( $seconds < 0 ) {
|
if ( $seconds < 0 ) {
|
||||||
$seconds = 0;
|
$seconds = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,11 +369,11 @@ function get_user_language ($id_user = null) {
|
||||||
if ($quick_language) {
|
if ($quick_language) {
|
||||||
$language = get_parameter('language', 0);
|
$language = get_parameter('language', 0);
|
||||||
|
|
||||||
if($language === 'default') {
|
if ($language === 'default') {
|
||||||
return $config['language'];
|
return $config['language'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($language !== 0) {
|
if ($language !== 0) {
|
||||||
return $language;
|
return $language;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -382,7 +382,7 @@ function get_user_language ($id_user = null) {
|
||||||
$id_user = $config['id_user'];
|
$id_user = $config['id_user'];
|
||||||
}
|
}
|
||||||
|
|
||||||
if($id_user !== null) {
|
if ($id_user !== null) {
|
||||||
$userinfo = get_user_info ($id_user);
|
$userinfo = get_user_info ($id_user);
|
||||||
if ($userinfo['language'] != 'default'){
|
if ($userinfo['language'] != 'default'){
|
||||||
return $userinfo['language'];
|
return $userinfo['language'];
|
||||||
|
@ -494,34 +494,37 @@ function human_time_description_raw ($seconds, $exactly = false, $units = 'large
|
||||||
if ($mins != 0) {
|
if ($mins != 0) {
|
||||||
$seconds = $seconds - ($mins * 60);
|
$seconds = $seconds - ($mins * 60);
|
||||||
|
|
||||||
if($hours == 0) {
|
if ($hours == 0) {
|
||||||
$returnTime .= "$mins $minutesString ";
|
$returnTime .= "$mins $minutesString ";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$returnTime = sprintf("%02d",$hours).':'.sprintf("%02d",$mins);
|
$returnTime = sprintf("%02d",$hours) . ':' .
|
||||||
|
sprintf("%02d",$mins);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($seconds != 0) {
|
if ($seconds != 0) {
|
||||||
if($hours == 0) {
|
if ($hours == 0) {
|
||||||
$returnTime .= "$seconds $secondsString ";
|
$returnTime .= "$seconds $secondsString ";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$returnTime = sprintf("%02d",$hours).':'.sprintf("%02d",$mins).':'.sprintf("%02d",$seconds);
|
$returnTime = sprintf("%02d",$hours) . ':' .
|
||||||
|
sprintf("%02d",$mins) . ':' .
|
||||||
|
sprintf("%02d",$seconds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$return = ' ';
|
$return = ' ';
|
||||||
|
|
||||||
if($returnDate != '') {
|
if ($returnDate != '') {
|
||||||
$return = $returnDate;
|
$return = $returnDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($returnTime != '') {
|
if ($returnTime != '') {
|
||||||
$return .= $returnTime;
|
$return .= $returnTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($return == ' ') {
|
if ($return == ' ') {
|
||||||
return $nowString;
|
return $nowString;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -634,7 +637,7 @@ function get_parameter_checkbox ($name, $default = '') {
|
||||||
$sent = get_parameter($name.'_sent', 0);
|
$sent = get_parameter($name.'_sent', 0);
|
||||||
|
|
||||||
// If is not sent, return the default
|
// If is not sent, return the default
|
||||||
if(!$sent) {
|
if (!$sent) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1156,7 +1159,7 @@ function is_ajax () {
|
||||||
* @return bool true if a result code is an error or false otherwise
|
* @return bool true if a result code is an error or false otherwise
|
||||||
*/
|
*/
|
||||||
function is_error($code) {
|
function is_error($code) {
|
||||||
if($code !== true AND ($code <= ERR_GENERIC || $code === false)) {
|
if ($code !== true AND ($code <= ERR_GENERIC || $code === false)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -1520,7 +1523,7 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
|
||||||
AND (tusuario_perfil.id_grupo IN (%s)
|
AND (tusuario_perfil.id_grupo IN (%s)
|
||||||
OR tusuario_perfil.id_grupo = 0)", $id_user, implode(', ', $parents_id));
|
OR tusuario_perfil.id_grupo = 0)", $id_user, implode(', ', $parents_id));
|
||||||
}
|
}
|
||||||
|
|
||||||
$rowdup = db_get_all_rows_sql ($query);
|
$rowdup = db_get_all_rows_sql ($query);
|
||||||
|
|
||||||
if (empty ($rowdup))
|
if (empty ($rowdup))
|
||||||
|
@ -1530,7 +1533,7 @@ function check_acl($id_user, $id_group, $access, $id_agent = 0) {
|
||||||
$acl_column = get_acl_column($access);
|
$acl_column = get_acl_column($access);
|
||||||
foreach ($rowdup as $row) {
|
foreach ($rowdup as $row) {
|
||||||
// For each profile for this pair of group and user do...
|
// For each profile for this pair of group and user do...
|
||||||
if(isset($row[$acl_column])) {
|
if (isset($row[$acl_column])) {
|
||||||
$result += $row[$acl_column];
|
$result += $row[$acl_column];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1437,9 +1437,9 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') {
|
||||||
//Show empty groups only if they have children with agents
|
//Show empty groups only if they have children with agents
|
||||||
//$group_array = array();
|
//$group_array = array();
|
||||||
|
|
||||||
foreach($children as $sub) {
|
foreach ($children as $sub) {
|
||||||
// If the group is quering previously, we ingore it
|
// If the group is quering previously, we ingore it
|
||||||
if(!in_array($sub['id_grupo'],$covered_groups)){
|
if (!in_array($sub['id_grupo'],$covered_groups)){
|
||||||
array_push($covered_groups, $sub['id_grupo']);
|
array_push($covered_groups, $sub['id_grupo']);
|
||||||
array_push($group_array, $sub['id_grupo']);
|
array_push($group_array, $sub['id_grupo']);
|
||||||
}
|
}
|
||||||
|
@ -1468,8 +1468,8 @@ function reporting_get_group_stats ($id_group = 0, $access = 'AR') {
|
||||||
$tags_restricted_groups = array_keys($group_restricted_data);
|
$tags_restricted_groups = array_keys($group_restricted_data);
|
||||||
|
|
||||||
$no_tags_restricted_groups = $group_array;
|
$no_tags_restricted_groups = $group_array;
|
||||||
foreach($no_tags_restricted_groups as $k => $v) {
|
foreach ($no_tags_restricted_groups as $k => $v) {
|
||||||
if(in_array($v, $tags_restricted_groups)) {
|
if (in_array($v, $tags_restricted_groups)) {
|
||||||
unset($no_tags_restricted_groups[$k]);
|
unset($no_tags_restricted_groups[$k]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2771,7 +2771,7 @@ function reporting_get_agent_module_info ($id_agent, $filter = false) {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if($filter != ''){
|
if ($filter != '') {
|
||||||
$filter = 'AND ';
|
$filter = 'AND ';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2915,9 +2915,9 @@ function reporting_header_content($mini, $content, $report, &$table, $title = fa
|
||||||
if ($period !== false && $content['period'] > 0) {
|
if ($period !== false && $content['period'] > 0) {
|
||||||
$data[] = $sizh . $period . $sizhfin;
|
$data[] = $sizh . $period . $sizhfin;
|
||||||
}
|
}
|
||||||
else if($content['period'] == 0) {
|
else if ($content['period'] == 0) {
|
||||||
$es = json_decode($content['external_source'], true);
|
$es = json_decode($content['external_source'], true);
|
||||||
if($es['date'] == 0) {
|
if ($es['date'] == 0) {
|
||||||
$date = __('Last data');
|
$date = __('Last data');
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -3845,7 +3845,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
// Do a security check on SQL coming from the user
|
// Do a security check on SQL coming from the user
|
||||||
$sql = check_sql ($sql);
|
$sql = check_sql ($sql);
|
||||||
|
|
||||||
if($sql != '') {
|
if ($sql != '') {
|
||||||
$result = db_get_all_rows_sql($sql);
|
$result = db_get_all_rows_sql($sql);
|
||||||
if ($result === false) {
|
if ($result === false) {
|
||||||
$result = array();
|
$result = array();
|
||||||
|
@ -4323,7 +4323,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
// Get events of the last 8 hours
|
// Get events of the last 8 hours
|
||||||
$events = events_get_group_events ($content['id_group'], 28800, $report['datetime']);
|
$events = events_get_group_events ($content['id_group'], 28800, $report['datetime']);
|
||||||
|
|
||||||
if($events === false) {
|
if ($events === false) {
|
||||||
$events = array();
|
$events = array();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5605,7 +5605,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$filter_groups = array ('offset' => (int) $offset,
|
$filter_groups = array ('offset' => (int) $offset,
|
||||||
'limit' => (int) $config['block_size']);
|
'limit' => (int) $config['block_size']);
|
||||||
|
|
||||||
if($id_group > 0) {
|
if ($id_group > 0) {
|
||||||
$filter_groups['id_grupo'] = $id_group;
|
$filter_groups['id_grupo'] = $id_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5626,10 +5626,6 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$nmodules = 0;
|
$nmodules = 0;
|
||||||
foreach ($modules_by_name as $module) {
|
foreach ($modules_by_name as $module) {
|
||||||
$nmodules++;
|
$nmodules++;
|
||||||
// Don't use pagination
|
|
||||||
/*if($nmodules > $block) { //Will show only the (block) first modules
|
|
||||||
continue;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
$file_name = string2image(ui_print_truncate_text($module['name'], 'module_small', false, true, false, '...'), false, false, 6, 270, '#90B165', 'FFF', 4, 0);
|
$file_name = string2image(ui_print_truncate_text($module['name'], 'module_small', false, true, false, '...'), false, false, 6, 270, '#90B165', 'FFF', 4, 0);
|
||||||
$table_data .= '<th width="22px">' . html_print_image($file_name, true, array('title' => $module['name']))."</th>";
|
$table_data .= '<th width="22px">' . html_print_image($file_name, true, array('title' => $module['name']))."</th>";
|
||||||
|
@ -5721,7 +5717,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!$match) {
|
if (!$match) {
|
||||||
$table_data .= "<td style='background-color: #DDD;'></td>";
|
$table_data .= "<td style='background-color: #DDD;'></td>";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5811,7 +5807,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
|
|
||||||
$table->colspan[1][0] = 2;
|
$table->colspan[1][0] = 2;
|
||||||
|
|
||||||
if($description != '') {
|
if ($description != '') {
|
||||||
$data[0] = $description;
|
$data[0] = $description;
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
}
|
}
|
||||||
|
@ -5822,7 +5818,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
break;
|
break;
|
||||||
case 'agent_configuration':
|
case 'agent_configuration':
|
||||||
|
|
||||||
reporting_header_content($mini, $content, $report, $table, __('Agent configuration: ').$agent_name);
|
reporting_header_content($mini, $content, $report, $table, __('Agent configuration: ').$agent_name);
|
||||||
|
|
||||||
$agent_name = agents_get_name ($content['id_agent']);
|
$agent_name = agents_get_name ($content['id_agent']);
|
||||||
|
@ -5845,7 +5841,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$table->colspan[1][5] = 2;
|
$table->colspan[1][5] = 2;
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
unset($data);
|
unset($data);
|
||||||
|
|
||||||
$sql = "SELECT * FROM tagente WHERE id_agente=".$content['id_agent'];
|
$sql = "SELECT * FROM tagente WHERE id_agente=".$content['id_agent'];
|
||||||
$agent_data = db_get_row_sql($sql);
|
$agent_data = db_get_row_sql($sql);
|
||||||
|
|
||||||
|
@ -5928,23 +5924,26 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$data[7] = db_get_value('intervalo', 'tagente', 'id_agente', $content['id_agent']);
|
$data[7] = db_get_value('intervalo', 'tagente', 'id_agente', $content['id_agent']);
|
||||||
else
|
else
|
||||||
$data[7] = $data_module['module_interval'];
|
$data[7] = $data_module['module_interval'];
|
||||||
|
|
||||||
|
|
||||||
$data[8] = $data_module['unit'];
|
$data[8] = $data_module['unit'];
|
||||||
|
|
||||||
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $id_agent_module);
|
$module_status = db_get_row('tagente_estado', 'id_agente_modulo', $id_agent_module);
|
||||||
modules_get_status($id_agent_module, $module_status['estado'], $module_status['datos'], $status, $title);
|
modules_get_status($id_agent_module, $module_status['estado'], $module_status['datos'], $status, $title);
|
||||||
$data[9] = ui_print_status_image($status, $title, true);
|
$data[9] = ui_print_status_image($status, $title, true);
|
||||||
|
|
||||||
$sql_tag = "SELECT name FROM ttag WHERE id_tag IN (
|
$sql_tag = "SELECT name
|
||||||
SELECT id_tag FROM ttag_module
|
FROM ttag
|
||||||
WHERE id_agente_modulo=$id_agent_module)";
|
WHERE id_tag IN (
|
||||||
|
SELECT id_tag
|
||||||
|
FROM ttag_module
|
||||||
|
WHERE id_agente_modulo = $id_agent_module)";
|
||||||
$tags = db_get_all_rows_sql($sql_tag);
|
$tags = db_get_all_rows_sql($sql_tag);
|
||||||
if ($tags === false)
|
if ($tags === false)
|
||||||
$tags = '';
|
$tags = '';
|
||||||
else
|
else
|
||||||
$tags = implode (",", $tags);
|
$tags = implode (",", $tags);
|
||||||
|
|
||||||
$data[10] = $tags;
|
$data[10] = $tags;
|
||||||
array_push ($table->data, $data);
|
array_push ($table->data, $data);
|
||||||
}
|
}
|
||||||
|
@ -5958,7 +5957,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$agents_list = db_get_all_rows_sql($sql);
|
$agents_list = db_get_all_rows_sql($sql);
|
||||||
if ($agents_list === false)
|
if ($agents_list === false)
|
||||||
$agents_list = array();
|
$agents_list = array();
|
||||||
|
|
||||||
$table->colspan[0][1] = 10;
|
$table->colspan[0][1] = 10;
|
||||||
|
|
||||||
$i = 1;
|
$i = 1;
|
||||||
|
@ -5996,7 +5995,7 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$data[5] = __('Enabled');
|
$data[5] = __('Enabled');
|
||||||
else
|
else
|
||||||
$data[5] = __('Disabled');
|
$data[5] = __('Disabled');
|
||||||
|
|
||||||
$table->colspan[$i][3] = 2;
|
$table->colspan[$i][3] = 2;
|
||||||
$table->colspan[$i][4] = 4;
|
$table->colspan[$i][4] = 4;
|
||||||
$table->colspan[$i][5] = 2;
|
$table->colspan[$i][5] = 2;
|
||||||
|
@ -6088,9 +6087,12 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
modules_get_status($id_agent_module, $module_status['estado'], $module_status['datos'], $status, $title);
|
modules_get_status($id_agent_module, $module_status['estado'], $module_status['datos'], $status, $title);
|
||||||
$data[9] = ui_print_status_image($status, $title, true);
|
$data[9] = ui_print_status_image($status, $title, true);
|
||||||
|
|
||||||
$sql_tag = "SELECT name FROM ttag WHERE id_tag IN (
|
$sql_tag = "SELECT name
|
||||||
SELECT id_tag FROM ttag_module
|
FROM ttag
|
||||||
WHERE id_agente_modulo=$id_agent_module)";
|
WHERE id_tag IN (
|
||||||
|
SELECT id_tag
|
||||||
|
FROM ttag_module
|
||||||
|
WHERE id_agente_modulo = $id_agent_module)";
|
||||||
$tags = db_get_all_rows_sql($sql_tag);
|
$tags = db_get_all_rows_sql($sql_tag);
|
||||||
if ($tags === false)
|
if ($tags === false)
|
||||||
$tags = '';
|
$tags = '';
|
||||||
|
@ -6126,7 +6128,9 @@ function reporting_render_report_html_item ($content, $table, $report, $mini = f
|
||||||
$start_date = $end_date - $period;
|
$start_date = $end_date - $period;
|
||||||
|
|
||||||
// Get item filters
|
// Get item filters
|
||||||
$filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . (int)$content['text'] . "'", false, true);
|
$filter = db_get_row_sql("SELECT *
|
||||||
|
FROM tnetflow_filter
|
||||||
|
WHERE id_sg = '" . (int)$content['text'] . "'", false, true);
|
||||||
if ($description == '') {
|
if ($description == '') {
|
||||||
$description = $filter['id_name'];
|
$description = $filter['id_name'];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue