function _removeOldCacheFiles() { // remove old tinymce cache files (to ensure any new tinymce changes are used) $cacheFiles = scandir_recursive(DATA_DIR, '|/tiny_mce_|', 0); // cache files have been called both tiny_mce_cache_* and tiny_mce_* foreach ($cacheFiles as $filepath) { unlink($filepath); } }
/** * array scandir_recursive(string $path) * * Given a path on the local file-system, will scan the given directory and returl all files. * This is numch like the scandir() function, but this one is recursive - it will scann all * subdirectories. This function may follow symlinks. */ function scandir_recursive($dir, $prefix = '') { $dir = rtrim($dir, "\\/"); $result = array(); foreach (scandir($dir) as $f) { if ($f !== '.' and $f !== '..') { if (is_dir($dir . '/' . $f)) { $result = array_merge($result, scandir_recursive($dir . '/' . $f, $prefix . $f . '/')); } else { $result[] = $prefix . $f; } } } return $result; }
function scandir_recursive($dir, $regexp = '', $depth = 99) { $matchingFiles = array(); if ($dirHandle = @opendir($dir)) { while (($file = readdir($dirHandle)) !== false) { if ($file == '.' || $file == '..') { continue; } $filepath = "{$dir}/{$file}"; if (is_file($filepath)) { // skip symolic links, etc if ($regexp && !preg_match($regexp, $filepath)) { continue; } $matchingFiles[] = $filepath; } elseif ($depth && is_dir($filepath)) { $newFiles = scandir_recursive($filepath, $regexp, $depth - 1); $matchingFiles = array_merge($matchingFiles, $newFiles); continue; } } closedir($dirHandle); } return $matchingFiles; }
$hooks[$name] = array('type' => $hookType, 'callers' => array(), 'plugins' => array()); } $hooks[$name]['callers'][$phpFileNiceName] = true; } } if (preg_match_all($hookInfo['pluginRegex'], $content, $matches)) { foreach ($matches[2] as $name) { if (!@$hooks[$name]) { $hooks[$name] = array('type' => $hookType, 'callers' => array(), 'plugins' => array()); } $hooks[$name]['plugins'][$phpFileNiceName] = true; } } } } $phpFiles = scandir_recursive('.', '/\\.php$/'); foreach ($phpFiles as $phpFile) { $phpFileNiceName = preg_replace('|^\\./|', '', $phpFile); $content = file_get_contents($phpFile); foreach ($hookTypes as $hookType => $hookInfo) { if (preg_match_all($hookInfo['pluginRegex'], $content, $matches)) { foreach ($matches[2] as $name) { if (!@$hooks[$name]) { $hooks[$name] = array('type' => $hookType, 'callers' => array(), 'plugins' => array()); } $hooks[$name]['plugins'][$phpFileNiceName] = true; } } } } ksort($hooks);