Skip to content

Instantly share code, notes, and snippets.

@matdave
Last active October 12, 2018 21:01
Show Gist options
  • Save matdave/29b970fae98537485450b0fa24127347 to your computer and use it in GitHub Desktop.
Save matdave/29b970fae98537485450b0fa24127347 to your computer and use it in GitHub Desktop.
filesModifiedSince
<?php
function filesModifiedSince($dir = "/", $modified = 0, $exclude = array()) {
$result = array();
$exclude = array_merge(array(".",".."), $exclude);
$limit = time() - $modified;
$cdir = scandir($dir);
foreach ($cdir as $key => $value)
{
if (!in_array($value,$exclude))
{
if (is_dir($dir . DIRECTORY_SEPARATOR . $value))
{
foreach(filesModifiedSince($dir . DIRECTORY_SEPARATOR . $value, $modified, $exclude) as $v){
$result[] = $v;
}
}
elseif(filemtime($dir . DIRECTORY_SEPARATOR . $value) > $limit)
{
$result[] = realpath ($dir . DIRECTORY_SEPARATOR . $value);
}
}
}
return $result;
}
$dir = $modx->getOption('base_path');
$modified = $modx->getOption('modified', $scriptProperties, 3600*24*2);
$exclude = array("manager","components","connectors","core");
print_r(filesModifiedSince($dir, $modified, $exclude));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment