cellpadding = 3; $table->cellspacing = 3; $table->width = '98%'; $table->class = 'databox'; $table->head = []; $table->data = []; $table->align = []; $table->size = []; $moduletype_name = modules_get_moduletype_name(modules_get_agentmodule_type($module_id)); $offset = (int) get_parameter('offset'); $block_size = (int) $config['block_size']; // The "columns" array is the number(and definition) of columns in the report: // $columns = array( // "COLUMN1" => array(ROW_FROM_DB_TABLE, FUNCTION_NAME_TO_FORMAT_THE_DATA, "align"=>COLUMN_ALIGNMENT, "width"=>COLUMN_WIDTH) // "COLUMN2" => array(ROW_FROM_DB_TABLE, FUNCTION_NAME_TO_FORMAT_THE_DATA, "align"=>COLUMN_ALIGNMENT, "width"=>COLUMN_WIDTH) // .... // ) // // For each row from the query, and for each column, we'll call the FUNCTION passing as argument // the value of the ROW. // $columns = []; $datetime_from = strtotime($date_from.' '.$time_from); $datetime_to = strtotime($date_to.' '.$time_to); if ($moduletype_name == 'log4x') { $table->width = '100%'; $sql_freestring = '%'.$freestring.'%'; if ($selection_mode == 'fromnow') { $sql_body = sprintf("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND message like '%s' AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, $sql_freestring, (get_system_time() - $period)); } else { $sql_body = sprintf("FROM tagente_datos_log4x WHERE id_agente_modulo = %d AND message like '%s' AND utimestamp >= %d AND utimestamp <= %d ORDER BY utimestamp DESC", $module_id, $sql_freestring, $datetime_from, $datetime_to); } $columns = [ 'Sev' => [ 'severity', 'modules_format_data', 'align' => 'center', 'width' => '70px' ], 'Message' => [ 'message', 'modules_format_verbatim', 'align' => 'left', 'width' => '45%' ], 'StackTrace' => [ 'stacktrace', 'modules_format_verbatim', 'align' => 'left', 'width' => '50%' ], ]; } else if (preg_match('/string/', $moduletype_name)) { $sql_freestring = '%'.$freestring.'%'; if ($selection_mode == 'fromnow') { $sql_body = sprintf(" FROM tagente_datos_string WHERE id_agente_modulo = %d AND datos like '%s' AND utimestamp > %d ORDER BY utimestamp DESC", $module_id, $sql_freestring, (get_system_time() - $period)); } else { $sql_body = sprintf(" FROM tagente_datos_string WHERE id_agente_modulo = %d AND datos like '%s' AND utimestamp >= %d AND utimestamp <= %d ORDER BY utimestamp DESC", $module_id, $sql_freestring, $datetime_from, $datetime_to); } $columns = [ 'Data' => [ 'datos', 'modules_format_data', 'align' => 'left' ], 'Time' => [ 'utimestamp', 'modules_format_time', 'align' => 'center' ], ]; } else { if ($selection_mode == 'fromnow') { $sql_body = sprintf(' FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp > %d ORDER BY utimestamp DESC', $module_id, (get_system_time() - $period)); } else { $sql_body = sprintf(' FROM tagente_datos WHERE id_agente_modulo = %d AND utimestamp >= %d AND utimestamp <= %d ORDER BY utimestamp DESC', $module_id, $datetime_from, $datetime_to); } $columns = [ 'Data' => [ 'datos', 'modules_format_data', 'align' => 'left' ], 'Time' => [ 'utimestamp', 'modules_format_time', 'align' => 'center' ], ]; } $sql_body = io_safe_output($sql_body); // Clean all codification characters $sql = 'SELECT * '.$sql_body; $sql_count = 'SELECT count(*) '.$sql_body; $count = db_get_value_sql($sql_count, $connection_handler); switch ($config['dbtype']) { case 'mysql': $sql .= ' LIMIT '.$offset.','.$block_size; break; case 'postgresql': $sql .= ' LIMIT '.$block_size.' OFFSET '.$offset; break; case 'oracle': $set = []; $set['limit'] = $block_size; $set['offset'] = $offset; $sql = oracle_recode_query($sql, $set); break; } $result = db_get_all_rows_sql($sql, false, true, $connection_handler); if ($result === false) { $result = []; } if (($config['dbtype'] == 'oracle') && ($result !== false)) { for ($i = 0; $i < count($result); $i++) { unset($result[$i]['rnum']); } } $header_title = __('Received data from').' '.modules_get_agentmodule_agent_alias($module_id).' / '.modules_get_agentmodule_name($module_id); echo "