$EXCLUDE_FILES = array(); } for ($i = 0; $i < count($EXCLUDE_FILES); $i++) { // Remove a file from the array if it does not exist if (!file_exists($EXCLUDE_FILES[$i])) { array_splice($EXCLUDE_FILES, $i, 1); $i--; continue; } $EXCLUDE_FILES[$i] = realpath($EXCLUDE_FILES[$i]); } //print_r($paths); foreach ($paths as $path) { unset($files); if (is_dir($path)) { $files = get_all_php_files($path, $EXCLUDE_FILES, $RECURSIVE); } else { if (is_file($path)) { $files[] = $path; } else { error("Unknown entity: {$path}"); } } //print_r($files); foreach ($files as $file) { if ($UNDO) { uninstrument($file); } else { instrument($file); } }
function get_all_php_files($base_path) { $list = scandir($base_path); $files = array(); foreach ($list as $item) { if (substr($item, 0, 1) == '.') { continue; } $special_dirs = array(api_get_path(SYS_TEST_PATH), api_get_path(SYS_COURSE_PATH), api_get_path(SYS_LANG_PATH), api_get_path(SYS_ARCHIVE_PATH)); if (in_array($base_path . $item . '/', $special_dirs)) { continue; } if (is_dir($base_path . $item)) { $files = array_merge($files, get_all_php_files($base_path . $item . '/')); } else { //only analyse php files $sub = substr($item, -4); if ($sub == '.php' or $sub == '.tpl') { $files[] = $base_path . $item; } } } $list = null; return $files; }