コード例 #1
0
ファイル: json.php プロジェクト: riton/HTTPsFS
function dir_to_array($path, $dir)
{
    $abs_path;
    if (isset($dir)) {
        $abs_path = "{$path}/{$dir}";
    } else {
        $abs_path = $path;
    }
    $dirh = opendir($abs_path);
    if ($dirh === false) {
        exit(1);
    }
    $full_content = array();
    while (($entry = readdir($dirh)) !== false) {
        if (preg_match('/^\\./', $entry) === 1) {
            continue;
        }
        $entry_t = filetype("{$abs_path}/{$entry}");
        if ($entry_t == "dir") {
            $content = dir_to_array($abs_path, $entry);
            array_push($full_content, $content);
        } else {
            $stats = stat("{$abs_path}/{$entry}");
            $size = $stats[7];
            array_push($full_content, array($entry, $size, format_url_to_ressource("{$abs_path}/{$entry}")));
        }
    }
    closedir($dirh);
    return array($dir => $full_content);
}
コード例 #2
0
ファイル: Page.php プロジェクト: ni-c/md-photo-blog
 /**
  * Get an array that represents directory tree
  *
  * @param string $directory     Directory path
  * @param bool $recursive         Include sub directories
  * @param bool $listDirs         Include directories on listing
  * @param bool $listFiles         Include files on listing
  * @param regex $exclude         Exclude paths that matches this regex
  */
 protected function dir_to_array($directory, $recursive = false, $listDirs = true, $listFiles = false, $exclude = '')
 {
     $array_items = array();
     $skip_by_exclude = false;
     $handle = opendir($directory);
     if ($handle) {
         while (false !== ($file = readdir($handle))) {
             preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git|md))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $file, $skip);
             if ($exclude) {
                 preg_match($exclude, $file, $skip_by_exclude);
             }
             if (!$skip && !$skip_by_exclude) {
                 if (is_dir($directory . DIRECTORY_SEPARATOR . $file)) {
                     if ($recursive) {
                         $array_items = array_merge($array_items, dir_to_array($directory . DIRECTORY_SEPARATOR . $file, $recursive, $listDirs, $listFiles, $exclude));
                     }
                     if ($listDirs) {
                         $file = $directory . DIRECTORY_SEPARATOR . $file;
                         $array_items[] = $file;
                     }
                 } else {
                     if ($listFiles) {
                         $file = $directory . DIRECTORY_SEPARATOR . $file;
                         $array_items[] = $file;
                     }
                 }
             }
         }
         closedir($handle);
     }
     return $array_items;
 }
コード例 #3
0
 /**
  * Converte uma arvorá diretória para um array com seus subníveis.
  * 
  * @param <string> $dir
  * @return <array>
  */
 static function to_array($dir)
 {
     $result = array();
     foreach (scandir($dir) as $key => $value) {
         if (!in_array($value, array('.', '..'))) {
             if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                 $result[$value] = dir_to_array($dir . DIRECTORY_SEPARATOR . $value);
             } else {
                 $result[] = $value;
             }
         }
     }
     return $result;
 }
コード例 #4
0
function dir_to_array($dir)
{
    $result = array();
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, array(".", ".."))) {
            if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                $result[$value] = dir_to_array($dir . DIRECTORY_SEPARATOR . $value);
            } else {
                $result[] = $value;
            }
        }
    }
    return $result;
}
コード例 #5
0
ファイル: index.php プロジェクト: egarcia87/MPO-Website
function dir_to_array($dir)
{
    $files = scandir($dir);
    $filelist = array();
    foreach ($files as $key => $value) {
        if (!in_array($value, array(".", "..", "lib", "skin"))) {
            // filter these
            if (is_dir($dir . "/" . $value)) {
                $filelist = array_merge($filelist, dir_to_array($dir . '/' . $value));
            } else {
                // only get those that end with (".owl", ".rdf")
                $ext = pathinfo($value, PATHINFO_EXTENSION);
                if (in_array($ext, array("owl", "rdf"))) {
                    $filelist[] = $dir . '/' . $value;
                }
            }
        }
    }
    return $filelist;
}
function dir_to_array($dir)
{
    static $result = array();
    global $blacklist_files, $blacklist_folders, $blacklist_extensions;
    $cdir = scandir($dir);
    foreach ($cdir as $key => $value) {
        if (!in_array($value, $blacklist_files)) {
            $ext = pathinfo($value, PATHINFO_EXTENSION);
            if (!$blacklist_extensions || !in_array($ext, $blacklist_extensions)) {
                if (is_dir($dir . DIRECTORY_SEPARATOR . $value)) {
                    if (!$blacklist_folders || !in_array(basename($dir), $blacklist_folders)) {
                        if ($dir != '.') {
                            $result += dir_to_array($dir . DIRECTORY_SEPARATOR . $value);
                        }
                    }
                } else {
                    $result[] = $dir . DIRECTORY_SEPARATOR . $value;
                }
            }
        }
    }
    return $result;
}
コード例 #7
0
ファイル: DirectoryComponent.php プロジェクト: ni-c/photocake
 /**
  * Get an array that represents directory tree
  *
  * @param string $directory     Directory path
  * @param bool $recursive         Include sub directories
  * @param bool $listDirs         Include directories on listing
  * @param bool $listFiles         Include files on listing
  * @param regex $exclude         Exclude paths that matches this regex
  * @return The files in the directory as array
  */
 private function dir_to_array($directory, $recursive = false, $listDirs = true, $listFiles = false, $exclude = '')
 {
     $array_items = array();
     $skip_by_exclude = false;
     if ($directory[strlen($directory) - 1] == DS) {
         $directory = substr($directory, 0, strlen($directory) - 1);
     }
     $handle = opendir($directory);
     if ($handle) {
         while (false !== ($file = readdir($handle))) {
             preg_match("/(^(([\\.]){1,2})\$|(\\.(svn|git|md))|(Thumbs\\.db|\\.DS_STORE))\$/iu", $file, $skip);
             if ($exclude) {
                 preg_match($exclude, $file, $skip_by_exclude);
             }
             if (!$skip && !$skip_by_exclude) {
                 if (is_dir($directory . DS . $file)) {
                     if ($recursive) {
                         $array_items = array_merge($array_items, dir_to_array($directory . DS . $file, $recursive, $listDirs, $listFiles, $exclude));
                     }
                     if ($listDirs) {
                         $file = $directory . DS . $file;
                         $array_items[] = $file;
                     }
                 } else {
                     if ($listFiles) {
                         $file = $directory . DS . $file;
                         $array_items[] = $file;
                     }
                 }
             }
         }
         closedir($handle);
     }
     asort($array_items);
     return $array_items;
 }
コード例 #8
0
 public function captcha_generator_view()
 {
     $fonts = dir_to_array(base_path("public/site-docs/captcha-fonts/") . "/");
     $data = ["route_info" => \sr::api("captcha-gene"), 'theme' => $this->themes[0], 'ng_app' => "myApp", 'ng_controller' => "main", "fonts" => $fonts];
     return $this->get_view("Apis.captcha-gene", $data);
 }