<?php /******************************************************************* * FileSystemBrowser.php * Copyright (C) 2006 Midnight Coders, LLC * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * The software is licensed under the GNU General Public License (GPL) * For details, see http://www.gnu.org/licenses/gpl.txt. ********************************************************************/ require_once("FolderItem.php"); require_once("FileItem.php"); class FileSystemBrowser { public function getRoot() { return $this->getDirectory("/"); } public function getDirectory($fullPath) { $rootInfo = array(); $scandir = scandir($fullPath); foreach ($scandir as $entry) { if($entry != '.' && $entry != '..') { if(is_dir($fullPath.$entry)) { $folder = new FolderItem(); $folder->getAtribute($fullPath, $entry); $rootInfo[] = $folder; } } } foreach ($scandir as $entry) { if(is_file($fullPath.$entry)) { $file = new FileItem(); $file->getFileSize($fullPath.$entry); $file->getAtribute($fullPath, $entry); $rootInfo[] = $file; } } return $rootInfo; } } ?>