/** * Is called with an array of files and timestamps to check if the file ages * have changed since these timestamps. * * Returns null when nothing changed or a structure of the changed objects */ protected function checkFilesChanged($files) { global $AUTHORISATION, $CORE; $changed = array(); foreach ($files as $file) { $parts = explode(',', $file); // Skip invalid requested files if (count($parts) != 3) { continue; } list($ty, $name, $age) = $parts; $age = (int) $age; // Try to fetch the current age of the requested file $cur_age = null; if ($ty == 'maincfg') { $cur_age = $CORE->getMainCfg()->getConfigFileAge(); } elseif ($ty == 'map') { if ($AUTHORISATION->isPermitted('Map', 'view', $name)) { $MAPCFG = new GlobalMapCfg($name); $MAPCFG->readMapConfig(); $cur_age = $MAPCFG->getFileModificationTime($age); } } // Check if the file has changed; Reply with the changed timestamps if ($cur_age !== null && $cur_age > $age) { $changed[$name] = $cur_age; } } if (count($changed) > 0) { return json_encode(array('status' => 'CHANGED', 'data' => $changed)); } else { return null; } }