Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed: Create a new function cacti_unserialize for PHP 5.4 and 7.0+ #5438

Merged
merged 1 commit into from
Aug 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions data_debug.php
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,7 @@ function debug_wizard() {
if (cacti_sizeof($checks)) {
foreach ($checks as $check) {
if (isset($check['info']) && $check['info'] != '') {
$info = unserialize($check['info'], array('allowed_classes' => false));
$info = cacti_unserialize($check['info']);
} else {
$info = '';
}
Expand Down Expand Up @@ -672,7 +672,7 @@ function debug_view() {
$check_exists = cacti_sizeof($check);

if (isset($check) && is_array($check)) {
$check['info'] = unserialize($check['info'], array('allowed_classes' => false));
$check['info'] = cacti_unserialize($check['info']);
}

$dtd = db_fetch_row_prepared('SELECT *
Expand Down
6 changes: 1 addition & 5 deletions graphs_new.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,7 @@ function host_reload_query() {
------------------- */

function host_new_graphs_save($host_id) {
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
$selected_graphs_array = unserialize(stripslashes(get_nfilter_request_var('selected_graphs_array')), array('allowed_classes' => false));
} else {
$selected_graphs_array = unserialize(stripslashes(get_nfilter_request_var('selected_graphs_array')));
}
$selected_graphs_array = cacti_unserialize(stripslashes(get_nfilter_request_var('selected_graphs_array')));

$values = array();
$form_data = array();
Expand Down
2 changes: 1 addition & 1 deletion lib/data_query.php
Original file line number Diff line number Diff line change
Expand Up @@ -1649,7 +1649,7 @@ function rewrite_snmp_enum_value($field_name, $value = null, $map = null) {

$map = $newmap;
} else {
$map = unserialize($map, array('allowed_classes' => false));
$map = cacti_unserialize($map);
}

if ($map === false || !is_array($map)) {
Expand Down
6 changes: 3 additions & 3 deletions lib/dsdebug.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ function dsdebug_poller_output(&$rrd_update_array) {
foreach($rrd_update_array as $item) {
if ($c['datasource'] == $item['local_data_id']) {
if (isset($item['times'][key($item['times'])])) {
$c['info'] = unserialize($c['info'], array('allowed_classes' => false));
$c['info'] = cacti_unserialize($c['info']);
$c['info']['last_result'] = $item['times'][key($item['times'])];
$c['info'] = serialize($c['info']);
db_execute_prepared('UPDATE data_debug SET `info` = ? WHERE `id` = ?', array($c['info'], $c['id']));
Expand Down Expand Up @@ -157,7 +157,7 @@ function dsdebug_poller_bottom() {

foreach ($checks as $c) {
$c['issue'] = array();
$info = unserialize($c['info'], array('allowed_classes' => false));
$info = cacti_unserialize($c['info']);

$dtd = db_fetch_row_prepared('SELECT *
FROM data_template_data
Expand Down Expand Up @@ -334,7 +334,7 @@ function dsdebug_run_repair($id) {
array($id));

if (cacti_sizeof($check)) {
$check['info'] = unserialize($check['info'], array('allowed_classes' => false));
$check['info'] = cacti_unserialize($check['info']);

if (isset($check['info']['rrd_match_array']['tune'])) {
$path = get_data_source_path($id, true);
Expand Down
8 changes: 8 additions & 0 deletions lib/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -7322,3 +7322,11 @@ function debounce_run_notification($id, $frequency = 7200) {

return false;
}

function cacti_unserialize($strobj) {
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
return unserialize($strobj, array('allowed_classes' => false));
} else {
return unserialize($strobj);
}
}
8 changes: 2 additions & 6 deletions managers.php
Original file line number Diff line number Diff line change
Expand Up @@ -913,11 +913,7 @@ function form_actions() {

if (isset_request_var('selected_items')) {
if (isset_request_var('action_receivers')) {
if (version_compare(PHP_VERSION, '7.0.0', '>=')) {
$selected_items = unserialize(stripslashes(get_nfilter_request_var('selected_graphs_array')), array('allowed_classes' => false));
} else {
$selected_items = unserialize(stripslashes(get_nfilter_request_var('selected_graphs_array')));
}
$selected_items = cacti_unserialize(stripslashes(get_nfilter_request_var('selected_graphs_array')));

if ($selected_items != false) {
if (get_nfilter_request_var('drp_action') == '1') { // delete
Expand All @@ -938,7 +934,7 @@ function form_actions() {
get_filter_request_var('id');
/* ==================================================== */

$selected_items = unserialize(stripslashes(get_nfilter_request_var('selected_items')), array('allowed_classes' => false));
$selected_items = cacti_unserialize(stripslashes(get_nfilter_request_var('selected_items')));

if ($selected_items !== false) {
if (get_nfilter_request_var('drp_action') == '1') { // disable
Expand Down