function search_files($dir, $prefix = '') { global $excludes; $files = array(); if ($dh = opendir($dir)) { while (($file = readdir($dh)) !== false) { if (!preg_match($excludes, $file)) { if (is_dir($dir . '/' . $file)) { $files = array_merge($files, search_files($dir . '/' . $file, $prefix . $file . '/')); } else { $files[] = $prefix . $file; } } } closedir($dh); } return $files; }
} } $path = "{$p}/{$f}"; $cont = file_get_contents($path); foreach ($search['key'] as $sk) { $pat_sk = "/{$sk} (.*)/i"; if (preg_match_all($pat_sk, $cont, $match_all)) { $match_all = array_unique($match_all[1]); foreach ($match_all as $ma) { foreach ($exclude['key'] as $ek) { if (!preg_match($ek, $ma)) { foreach ($replace as $s => $r) { $ma = preg_replace($s, $r, $ma); } $ret[$path][] = trim($ma); } } } } } } } return $ret; } print_r(search_files(PATH_BASE . "/implements")); exit; // }}} $r = []; foreach ($path['desc'] as $path) { $desc_list = get_dir_list(PATH_BASE . '/' . $path); }
function search_files($path) { global $moduleDir, $res_acts, $suggestionList; $fp = opendir($path); while ($f = readdir($fp)) { if (preg_match("#^\\.+\$#", $f)) { continue; } // ignore symbolic links if ($f == 'mod.xml') { continue; } $file_full_path = $path . '/' . $f; if (is_dir($file_full_path)) { search_files($file_full_path); } else { $path_parts = pathinfo($f); if ($path_parts['extension'] == 'xml') { $xml = simplexml_load_file($file_full_path); $fname = str_replace($moduleDir, '', $file_full_path); if (isset($xml['Access']) && $xml['Access'] != '') { echo " - {$fname}, Access=" . $xml['Access'] . PHP_EOL; } else { echo " - {$fname}, Access=" . PHP_EOL; $suggestedAccess = ""; foreach ($res_acts as $tmp) { $k = $tmp[0]; $v = $tmp[1]; $kls = preg_split("/[._-\\s]+/", $v); $_k = $kls[count($kls) - 1]; //print_r($tmp); echo "$_k, ".$xml['Name'].PHP_EOL; exit; if (stripos($xml['Name'], $_k) !== false) { $suggestedAccess = $k . "." . $v; break; } } $suggestionList[$fname] = $suggestedAccess; } } } } }