share
9 years ago
.htaccess
11 years ago
anti_malware.php
5 years ago
class-api.php
4 weeks ago
class-centralised-logging.php
4 weeks ago
class-coupon.php
7 months ago
class-email-sodium.php
2 months ago
class-firewall-log.php
4 weeks ago
class-helpers.php
9 months ago
class-import-export.php
4 months ago
class-ip.php
5 months ago
class-nfw-database.php
7 months ago
class-plugin-upgrade.php
4 weeks ago
class-security-updates.php
4 weeks ago
class-session.php
4 weeks ago
class_mail.php
2 months ago
firewall.php
4 weeks ago
fw_fileguard.php
5 months ago
fw_livelog.php
1 year ago
help.php
4 weeks ago
helpers.php
4 weeks ago
i18n-extra.php
4 weeks ago
i18n.php
1 year ago
index.html
13 years ago
init_update.php
2 years ago
install.php
1 year ago
install_default.php
4 weeks ago
loader.php
7 months ago
mail_template_firewall.php
1 year ago
mail_template_plugin.php
4 weeks ago
scheduled_tasks.php
3 years ago
settings_dashboard.php
4 weeks ago
settings_dashboard_about.php
2 months ago
settings_dashboard_statistics.php
2 months ago
settings_event_notifications.php
4 weeks ago
settings_events.php
2 months ago
settings_firewall_options.php
2 months ago
settings_firewall_policies.php
4 weeks ago
settings_login_protection.php
2 months ago
settings_logs.php
4 weeks ago
settings_logs_firewall_log.php
4 weeks ago
settings_logs_live_log.php
2 months ago
settings_monitoring.php
2 months ago
settings_monitoring_file_check.php
2 months ago
settings_monitoring_file_guard.php
2 months ago
settings_network.php
2 months ago
settings_security_rules.php
2 months ago
settings_security_rules_editor.php
4 weeks ago
settings_security_rules_update.php
4 weeks ago
sign.pub
7 years ago
thickbox.php
4 years ago
widget.php
3 years ago
wpplus.php
4 months ago
class-helpers.php
81 lines
| 1 | <?php |
| 2 | /* |
| 3 | +=====================================================================+ |
| 4 | | _ _ _ _ _____ _ _ _ | |
| 5 | | | \ | (_)_ __ (_) __ _| ___(_)_ __ _____ ____ _| | | | |
| 6 | | | \| | | '_ \ | |/ _` | |_ | | '__/ _ \ \ /\ / / _` | | | | |
| 7 | | | |\ | | | | || | (_| | _| | | | | __/\ V V / (_| | | | | |
| 8 | | |_| \_|_|_| |_|/ |\__,_|_| |_|_| \___| \_/\_/ \__,_|_|_| | |
| 9 | | |__/ | |
| 10 | | (c) NinTechNet Limited ~ https://nintechnet.com/ | |
| 11 | +=====================================================================+ |
| 12 | */ |
| 13 | |
| 14 | if ( class_exists('NinjaFirewall_helpers') ) { |
| 15 | return; |
| 16 | } |
| 17 | |
| 18 | class NinjaFirewall_helpers { |
| 19 | |
| 20 | |
| 21 | /** |
| 22 | * Retrieve and return matching files from a directory. |
| 23 | * Replacement for the PHP glob() function to make file search compatible with remote files. |
| 24 | */ |
| 25 | public static function nfw_glob( $directory, $regex, $pathname = false, $sortname = true ) { |
| 26 | |
| 27 | $list = []; |
| 28 | |
| 29 | if (! is_dir( $directory ) ) { |
| 30 | return $list; |
| 31 | } |
| 32 | |
| 33 | foreach ( new DirectoryIterator( $directory ) as $finfo ) { |
| 34 | if (! $finfo->isDot() && preg_match("`$regex`", $finfo->getFilename() ) ) { |
| 35 | if ( $pathname ) { |
| 36 | $list[] = $finfo->getPathname(); |
| 37 | } else { |
| 38 | $list[] = $finfo->getFilename(); |
| 39 | } |
| 40 | } |
| 41 | } |
| 42 | if ( $sortname === true ) { |
| 43 | asort( $list ); |
| 44 | } |
| 45 | |
| 46 | return $list; |
| 47 | } |
| 48 | |
| 49 | |
| 50 | /** |
| 51 | * Retrieve and return matching files from a directory, recursively. |
| 52 | * Replacement for the PHP glob() function to make file search compatible with remote files. |
| 53 | */ |
| 54 | public static function nfw_glob_recursive( $directory, $regex, $pathname = false ) { |
| 55 | |
| 56 | $list = []; |
| 57 | |
| 58 | if (! is_dir( $directory ) ) { |
| 59 | return $list; |
| 60 | } |
| 61 | |
| 62 | $dir_iterator = new RecursiveDirectoryIterator( $directory ); |
| 63 | $iterator = new RecursiveIteratorIterator( $dir_iterator ); |
| 64 | |
| 65 | foreach ( $iterator as $finfo ) { |
| 66 | if ( preg_match("`$regex`", $finfo->getFilename() ) ) { |
| 67 | if ( $pathname ) { |
| 68 | $list[] = $finfo->getPathname(); |
| 69 | } else { |
| 70 | $list[] = $finfo->getFilename(); |
| 71 | } |
| 72 | } |
| 73 | } |
| 74 | return $list; |
| 75 | } |
| 76 | |
| 77 | } |
| 78 | |
| 79 | // --------------------------------------------------------------------- |
| 80 | // EOF |
| 81 |