-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsplice_dir_mapper.php
More file actions
1 lines (1 loc) · 1.22 KB
/
splice_dir_mapper.php
File metadata and controls
1 lines (1 loc) · 1.22 KB
1
<?php class treeview {private $files;private $folder;function __construct( $path ) {$files = array();if( file_exists( $path)) {if( $path[ strlen( $path ) - 1 ] == '/' )$this->folder = $path;else$this->folder = $path . '/';$this->dir = opendir( $path );while(( $file = readdir( $this->dir ) ) != false )$this->files[] = $file;closedir( $this->dir );}}function create_tree( ) {if( count( $this->files ) > 2 ) {natcasesort( $this->files );$list = '<ul class="filetree" style="display: none;">';foreach( $this->files as $file ) {if( file_exists( $this->folder . $file ) && $file != '.' && $file != '..' && is_dir( $this->folder . $file )) {$list .= '<li class="folder collapsed"><a href="#" rel="' . htmlentities( $this->folder . $file ) . '/">' . htmlentities( $file ) . '</a></li>';}}foreach( $this->files as $file ) {if( file_exists( $this->folder . $file ) && $file != '.' && $file != '..' && !is_dir( $this->folder . $file )) {$ext = preg_replace('/^.*\./', '', $file);$list .= '<li class="file ext_' . $ext . '"><a href="#" rel="' . htmlentities( $this->folder . $file ) . '">' . htmlentities( $file ) . '</a></li>';}}$list .= '</ul>';return $list;}}}$path = urldecode( $_REQUEST['dir'] );$tree = new treeview( $path );echo $tree->create_tree();?>