Merge branch 'ent-11318-item-informe-inventory-inventory-en-metaconsola-no-funciona' into 'develop'

Ent 11318 item informe inventory inventory en metaconsola no funciona

See merge request artica/pandorafms!5935
This commit is contained in:
Matias Didier 2023-05-25 09:32:32 +00:00
commit 04f802aa40
3 changed files with 40 additions and 8 deletions

View File

@ -518,8 +518,9 @@ foreach ($items as $item) {
}
$agent_name_db = implode('<br>', $agent_name_db);
$module_name_db = implode('<br>', $modules);
if (is_array($modules) === true) {
$module_name_db = implode('<br>', $modules);
}
} else {
$agent_id = agents_get_agent_id_by_module_id($item['id_agent_module']);
$agent_name = agents_get_name($agent_id);

View File

@ -2197,9 +2197,12 @@ switch ($action) {
'id_custom'
);
if ($values['treport_custom_sql_id'] == 0) {
$values['external_source'] = get_parameter(
'sql'
);
$sql = get_parameter('sql', '');
if ($sql !== '') {
$good_format = db_validate_sql($sql);
}
$values['external_source'] = $sql;
}
$values['historical_db'] = get_parameter(
@ -2936,9 +2939,12 @@ switch ($action) {
'id_custom'
);
if ($values['treport_custom_sql_id'] == 0) {
$values['external_source'] = get_parameter(
'sql'
);
$sql = get_parameter('sql', '');
if ($sql !== '') {
$good_format = db_validate_sql($sql);
}
$values['external_source'] = $sql;
}
$values['historical_db'] = get_parameter(

View File

@ -2555,3 +2555,28 @@ function db_get_column_type(string $table, string $column='')
return $result;
}
/**
* Validate sql query.
*
* @param string $sql Query for validate.
*
* @return boolean True if query is valid.
*/
function db_validate_sql(string $sql)
{
try {
error_reporting(0);
db_process_sql_begin();
$result = db_process_sql(io_safe_output($sql));
} catch (Exception $e) {
// Catch all posible errors.
$result = false;
} finally {
db_process_sql_rollback();
error_reporting(E_ALL);
}
return ($result !== false) ? true : false;
}