Example #1
0
function dir2array($dir, $content)
{
    if ($dir[strlen($dir) - 1] != '/') {
        $dir .= '/';
    }
    if (!is_dir($dir)) {
        return array();
    }
    $dir_handle = opendir($dir);
    $array = array();
    while ($object = readdir($dir_handle)) {
        if (!in_array($object, array('.', '..'))) {
            $filepath = $dir . $object;
            $file_object = array('name' => $object, 'path' => $dir, 'size' => filesize($filepath), 'type' => filetype($filepath), 'node' => fileinode($filepath), 'group' => filegroup($filepath), 'time' => getTime($filepath), 'perms' => getPermissions($filepath));
            if ($file_object['type'] == 'dir') {
                if ($content == true) {
                    $file_object['content'] = dir2array($filepath, $content);
                }
            } else {
                if ($content == true) {
                    $file_object['content'] = file2base64($filepath);
                }
                $file_object['mime'] = getMime($filepath);
            }
            $array[] = $file_object;
        }
    }
    return $array;
}
Example #2
0
 public function file2base64($file)
 {
     return file2base64($file);
 }