Last active
October 12, 2018 21:01
-
-
Save matdave/29b970fae98537485450b0fa24127347 to your computer and use it in GitHub Desktop.
filesModifiedSince
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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