= ?", [$last_time]); if ($mibcache_changed !== null || file_exists($path_mibcache) === false) { $objects = db_fetch_assoc('SELECT `oid`, LOWER(type) as type, `otype`, `max-access`, `value` FROM snmpagent_cache'); if (cacti_sizeof($objects)) { $oids = []; foreach ($objects as &$object) { $oids[] = $object['oid']; $object = ($object['otype'] == 'DATA' && $object['max-access'] != 'not-accessible') ? ['type' => $object['type'], 'value' => $object['value']] : false; } // natural sorting with MySQL is not available - especially not for OIDs natsort($oids); $last_accessible_object = false; $next_accessible_object_required = []; foreach ($oids as $key => $oid) { if ($objects[$key]) { if ($last_accessible_object) { $cache[$last_accessible_object]['next'] = $oid; } if (cacti_sizeof($next_accessible_object_required) > 0) { foreach ($next_accessible_object_required as $next_accessible_object_required_oid) { $cache[$next_accessible_object_required_oid]['next'] = $oid; } $next_accessible_object_required = []; } $last_accessible_object = $oid; } else { $next_accessible_object_required[] = $oid; } $cache[$oid] = $objects[$key]; } } // create lock file $lock = fopen($path_mibcache_lock, 'w'); if (is_resource($lock)) { // Note: If SNMPAgent plugin has been disabled the cache will be truncated automatically if (cacti_sizeof($cache)) { file_put_contents($path_mibcache, '