mirror of
https://github.com/stylersnico/librenms.git
synced 2026-07-12 16:06:25 +02:00
Sanity!
This commit is contained in:
@@ -31,6 +31,7 @@ include_once($config['install_dir'].'/html/includes/authentication/'.$config['au
|
||||
* @return string|boolean
|
||||
*/
|
||||
function GenSQL($rule) {
|
||||
$rule = htmlspecialchars_decode($rule);
|
||||
$rule = RunMacros($rule);
|
||||
if( empty($rule) ) {
|
||||
//Cannot resolve Macros due to recursion. Rule is invalid.
|
||||
|
||||
@@ -1255,3 +1255,16 @@ function get_port_id ($ports_mapped, $port, $port_association_mode) {
|
||||
|
||||
return $port_id;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize
|
||||
* @param mixed $item Reference to Item
|
||||
* @param mixed $key Key
|
||||
* @return void
|
||||
*/
|
||||
function sanitize_array(&$item, $key) {
|
||||
$tmp = htmlspecialchars($item);
|
||||
if( !empty($tmp) ){
|
||||
$item = $tmp;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -266,6 +266,7 @@ function dbFetchRows($sql, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($rows,'sanitize_array');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
@@ -333,6 +334,7 @@ function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($row,'sanitize_array');
|
||||
return $row;
|
||||
}
|
||||
else {
|
||||
|
||||
@@ -267,6 +267,7 @@ function dbFetchRows($sql, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$rows,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($rows,'sanitize_array');
|
||||
return $rows;
|
||||
}
|
||||
|
||||
@@ -334,6 +335,7 @@ function dbFetchRow($sql=null, $parameters=array(), $nocache=false) {
|
||||
if ($config['memcached']['enable'] && $nocache === false) {
|
||||
$config['memcached']['resource']->set(hash('sha512',$sql.'|'.serialize($parameters)),$row,$config['memcached']['ttl']);
|
||||
}
|
||||
array_walk_recursive($row,'sanitize_array');
|
||||
return $row;
|
||||
}
|
||||
else {
|
||||
|
||||
Reference in New Issue
Block a user