Diff
8 years ago
dashboard
7 years ago
rest-api
7 years ago
.htaccess
7 years ago
Diff.php
14 years ago
GeoLite2-Country.mmdb
7 years ago
IPTraf.php
8 years ago
IPTrafList.php
7 years ago
WFLSPHP52Compatability.php
7 years ago
compat.php
8 years ago
conntest.php
7 years ago
cronview.php
8 years ago
dbview.php
8 years ago
diffResult.php
8 years ago
email_genericAlert.php
7 years ago
email_newIssues.php
7 years ago
email_unlockRequest.php
8 years ago
email_unsubscribeRequest.php
7 years ago
flags.php
7 years ago
live_activity.php
8 years ago
menu_dashboard.php
7 years ago
menu_dashboard_options.php
7 years ago
menu_firewall.php
7 years ago
menu_firewall_blocking.php
7 years ago
menu_firewall_blocking_options.php
8 years ago
menu_firewall_waf.php
7 years ago
menu_firewall_waf_options.php
7 years ago
menu_options.php
7 years ago
menu_scanner.php
7 years ago
menu_scanner_credentials.php
8 years ago
menu_scanner_options.php
8 years ago
menu_support.php
7 years ago
menu_tools.php
7 years ago
menu_tools_diagnostic.php
7 years ago
menu_tools_importExport.php
7 years ago
menu_tools_livetraffic.php
7 years ago
menu_tools_twoFactor.php
7 years ago
menu_tools_whois.php
8 years ago
menu_wordfence_central.php
7 years ago
noc1.key
7 years ago
sysinfo.php
8 years ago
unknownFiles.php
8 years ago
viewFullActivityLog.php
8 years ago
wf503.php
7 years ago
wfAPI.php
7 years ago
wfActivityReport.php
7 years ago
wfAdminNoticeQueue.php
8 years ago
wfArray.php
7 years ago
wfBrowscap.php
8 years ago
wfBrowscapCache.php
7 years ago
wfBulkCountries.php
7 years ago
wfCache.php
9 years ago
wfCentralAPI.php
7 years ago
wfConfig.php
7 years ago
wfCrawl.php
8 years ago
wfCredentialsController.php
7 years ago
wfCrypt.php
7 years ago
wfDB.php
7 years ago
wfDashboard.php
7 years ago
wfDateLocalization.php
8 years ago
wfDiagnostic.php
7 years ago
wfDict.php
8 years ago
wfDirectoryIterator.php
7 years ago
wfHelperBin.php
11 years ago
wfHelperString.php
11 years ago
wfIPWhitelist.php
7 years ago
wfImportExportController.php
7 years ago
wfIssues.php
7 years ago
wfJWT.php
7 years ago
wfLockedOut.php
7 years ago
wfLog.php
7 years ago
wfMD5BloomFilter.php
8 years ago
wfModuleController.php
7 years ago
wfNotification.php
8 years ago
wfOnboardingController.php
7 years ago
wfPersistenceController.php
8 years ago
wfRESTAPI.php
7 years ago
wfScan.php
7 years ago
wfScanEngine.php
7 years ago
wfSchema.php
7 years ago
wfStyle.php
7 years ago
wfSupportController.php
7 years ago
wfUnlockMsg.php
7 years ago
wfUpdateCheck.php
8 years ago
wfUtils.php
7 years ago
wfVersionCheckController.php
8 years ago
wfView.php
10 years ago
wfViewResult.php
8 years ago
wordfenceClass.php
7 years ago
wordfenceConstants.php
7 years ago
wordfenceHash.php
7 years ago
wordfenceScanner.php
7 years ago
wordfenceURLHoover.php
7 years ago
wfDirectoryIterator.php
89 lines
| 1 | <?php |
| 2 | |
| 3 | abstract class wfDirectoryIterator { |
| 4 | |
| 5 | abstract public function file($file); |
| 6 | |
| 7 | /** |
| 8 | * @var string |
| 9 | */ |
| 10 | private $directory; |
| 11 | |
| 12 | /** |
| 13 | * @var int |
| 14 | */ |
| 15 | private $directory_limit; |
| 16 | |
| 17 | |
| 18 | private $directories_entered = array(); |
| 19 | private $directories_processed = array(); |
| 20 | |
| 21 | /** |
| 22 | * @var callback |
| 23 | */ |
| 24 | private $callback; |
| 25 | /** |
| 26 | * @var int |
| 27 | */ |
| 28 | private $max_iterations; |
| 29 | private $iterations; |
| 30 | |
| 31 | /** |
| 32 | * @param string $directory |
| 33 | * @param int $max_files_per_directory |
| 34 | * @param int $max_iterations |
| 35 | */ |
| 36 | public function __construct($directory = ABSPATH, $max_files_per_directory = 20000, $max_iterations = 1000000) { |
| 37 | $this->directory = $directory; |
| 38 | $this->directory_limit = $max_files_per_directory; |
| 39 | $this->max_iterations = $max_iterations; |
| 40 | } |
| 41 | |
| 42 | public function run() { |
| 43 | $this->iterations = 0; |
| 44 | $this->scan($this->directory); |
| 45 | } |
| 46 | |
| 47 | protected function scan($dir) { |
| 48 | $dir = rtrim($dir, DIRECTORY_SEPARATOR); |
| 49 | $handle = opendir($dir); |
| 50 | $file_count = 0; |
| 51 | while ($file = readdir($handle)) { |
| 52 | if ($file == '.' || $file == '..') { |
| 53 | continue; |
| 54 | } |
| 55 | $file_path = $dir . '/' . $file; |
| 56 | $real_path = realpath($file_path); |
| 57 | if (isset($this->directories_processed[$real_path]) || isset($this->directories_entered[$real_path])) { //Already processed or being processed, possibly a recursive symlink |
| 58 | continue; |
| 59 | } |
| 60 | |
| 61 | else if (is_dir($file_path)) { |
| 62 | $this->directories_entered[$real_path] = 1; |
| 63 | if ($this->scan($file_path) === false) { |
| 64 | closedir($handle); |
| 65 | return false; |
| 66 | } |
| 67 | $this->directories_processed[$real_path] = 1; |
| 68 | unset($this->directories_entered[$real_path]); |
| 69 | } |
| 70 | else { |
| 71 | if ($this->file($file_path) === false) { |
| 72 | closedir($handle); |
| 73 | return false; |
| 74 | } |
| 75 | } |
| 76 | if (++$file_count >= $this->directory_limit) { |
| 77 | break; |
| 78 | } |
| 79 | if (++$this->iterations >= $this->max_iterations) { |
| 80 | closedir($handle); |
| 81 | return false; |
| 82 | } |
| 83 | } |
| 84 | closedir($handle); |
| 85 | return true; |
| 86 | } |
| 87 | } |
| 88 | |
| 89 |