class webfm_searchFiles in Web File Manager 5
Same name and namespace in other branches
- 5.2 webfm.module \webfm_searchFiles
Class to search for files matching a regexp pattern
Hierarchy
- class \webfm_searchFiles
Expanded class hierarchy of webfm_searchFiles
File
- ./
webfm.module, line 2363
View source
class webfm_searchFiles {
var $count = 0;
var $files = array();
var $hidefilepattern;
var $uid = 0;
//Constructor
function webfm_searchFiles($root_dir, $dir, $searchpattern, $regexpsearch = FALSE, $user) {
$this->hidefilepattern = "^(CVS|\\..*)\$";
/*
if(!$regexpsearch) {
$searchpattern = "^".str_replace("*", ".*", str_replace("?", ".", str_replace(".", "\.", $searchpattern)))."$";
}
*/
$this->uid = $user;
$this
->searchFilesRecur($root_dir, $dir, $searchpattern);
}
function get_files() {
return $this->files;
}
function get_count() {
return $this->count;
}
function build_file_list($name, $path, $id) {
$sfd = new stdClass();
$sfd->n = $name;
$sfd->p = $path;
$sfd->id = $id;
$this->files[] = $sfd;
$this->count++;
}
function searchFilesRecur($root_dir, $dir, $searchpattern) {
$dir = rtrim($dir, '/');
//hide filesys root by not returning full path
$full_dir = $root_dir . $dir;
$handle = @opendir($full_dir);
while ($file = @readdir($handle)) {
if (@is_dir($full_dir . "/" . $file) && $file != "." && $file != "..") {
$this
->searchFilesRecur($root_dir, $dir . "/" . $file, $searchpattern);
}
else {
if (ereg(strtolower($searchpattern), strtolower($file)) && !ereg($this->hidefilepattern, $file)) {
if ($frec = webfm_get_file_record('', $full_dir . "/" . $file)) {
//return files in db (role level permission)
if ($this->uid == 1 || $this->uid == $frec->uid || webfm_file_view_access($frec)) {
$this
->build_file_list($file, $dir, $frec->fid);
}
}
else {
if ($this->uid == 1) {
//admins can search files not in db
$this
->build_file_list($file, $dir, 0);
}
}
}
}
}
@closedir($handle);
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
webfm_searchFiles:: |
property | |||
webfm_searchFiles:: |
property | |||
webfm_searchFiles:: |
property | |||
webfm_searchFiles:: |
property | |||
webfm_searchFiles:: |
function | |||
webfm_searchFiles:: |
function | |||
webfm_searchFiles:: |
function | |||
webfm_searchFiles:: |
function | |||
webfm_searchFiles:: |
function |