|
|
|
|
|
|
| |
| <?php
/**
* @category PHP4 DirectoryIterator class
* @version 0.0.1
* @author Adrian Rotea <adirotea@yahoo.com>
* @copyright Copyright © 2005, Adrian Rotea <adirotea@yahoo.com>
*
* This class implements the SPL DirectoryIterator in PHP4.
* Very usefull if wanting to traverse directories in an OO style
*
* Usage:
* similar with the PHP5 DirectoryIterator:
<code>
$files = array();
$folder = new DirectoryIterator('FolderName');
while ($folder->valid()) {
$files[] = array(
$folder->getPath(),
$folder->getFileName(),
$folder->getPathName(),
$folder->getPerms(),
$folder->getInode(),
$folder->getSize(),
$folder->getOwner(),
$folder->getGroup(),
$folder->getATime(),
$folder->getMTime(),
$folder->getCTime(),
$folder->getType(),
$folder->isWritable(),
$folder->isReadable(),
$folder->isExecutable(),
$folder->isFile(),
$folder->isDir(),
$folder->isDot(),
$folder->isLink(),
);
$folder->next();
}
print_r($files);
</code>
*/
if (!class_exists('DirectoryIterator')) {
class DirectoryIterator {
var $key;
var $current;
var $valid = true;
var $entry;
var $path;
var $handle;
/** Construct a directory iterator from a path-string.
*
* \param $path directory to iterate.
*/
function DirectoryIterator($path) {
if (substr($path, strlen($path) - 1, 1) != '/') {
$path = $path . '/';
}
$this->handle = opendir($path);
$this->path = $path;
}
/** \return The opened path.
*/
function getPath() {
return $this->path;
}
/** \return The current file name.
*/
function getFileName() {
return $this->entry;
}
/** \return The current entries path and file name.
*/
function getPathName() {
return $this->getPath() . $this->getFileName();
}
/** \return The current entry's permissions.
*/
function getPerms() {
return fileperms($this->getPathName());
}
/** \return The current entry's inode.
*/
function getInode() {
return fileinode($this->getPathName());
}
/** \return The current entry's size in bytes .
*/
function getSize() {
return filesize($this->getPathName());
}
/** \return The current entry's owner name.
*/
function getOwner() {
return fileowner($this->getPathName());
}
/** \return The current entry's group name.
*/
function getGroup() {
return filegroup($this->getPathName());
}
/** \return The current entry's last access time.
*/
function getATime() {
return fileatime($this->getPathName());
}
/** \return The current entry's last modification time.
*/
function getMTime() {
return filemtime($this->getPathName());
}
/** \return The current entry's last change time.
*/
function getCTime() {
return filectime($this->getPathName());
}
/** \return The current entry's size in bytes .
*/
function getType() {
return filetype($this->getPathName());
}
/** \return Whether the current entry is writeable.
*/
function isWritable() {
return is_writable($this->getPathName());
}
/** \return Whether the current entry is readable.
*/
function isReadable() {
return is_readable($this->getPathName());
}
/** \return Whether the current entry is executable.
*/
function isExecutable() {
if (function_exists('is_executable')) {
return is_executable($this->getPathName());
}
}
/** \return Whether the current entry is .
*/
function isFile() {
return is_file($this->getPathName());
}
/** \return Whether the current entry is a directory.
*/
function isDir() {
return is_dir($this->getPathName());
}
/** \return Whether the current entry is either '.' or '..'.
*/
function isDot() {
return $this->isDir() && ($this->entry == '.' || $this->entry == '..');
}
/** \return whether the current entry is a link.
*/
function isLink() {
return is_link($this->getPathName());
}
/** \Move to next entry.
*/
function next() {
$this->valid = $this->getFile();
$this->key++;
}
/** \Rewind dir back to the start.
*/
function rewind() {
$this->key = 0;
rewinddir($this->handle);
$this->valid = $this->getFile();
}
/** \Check whether dir contains more entries.
*/
function valid() {
if ($this->valid === false) {
$this->close();
}
return $this->valid;
}
/** \Return current dir entry.
*/
function key() {
return $this->key;
}
/** \Return this.
*/
function current() {
return $this;
}
/** \Close dir.
*/
function close() {
closedir($this->handle);
}
function getFile() {
if ( false !== ($file = readdir($this->handle)) ) {
$this->entry = $file;
return true;
} else {
return false;
}
}
}
}
?> | | |
|
| file class , uploade file , download file already uploaded on another website Categories : PHP, PHP Classes, Filesystem, Web Services | | | Display list of files within current and subdirectories (recursively) showing
each file as an anchored link and each directory as a category header. Categories : Filesystem, Directories, Arrays, PHP | | | Extended Get File List Function Categories : PHP, Filesystem, Search, Directories | | | Class that allows the PHP developer to create and manage UNIX like password files suitable for use as Apache authentication password files.
Categories : HTTP, PHP, PHP Classes, Filesystem | | | 3 lines of Code to extract Tar, Zip, Gzip etc.. Categories : PHP, Filesystem, PHP Classes, Compression | | | A File Browser Class.To Read Drives,Directories and Files .Files writing is also possible Categories : PHP, PHP Classes, Filesystem | | | Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support Categories : PHP, FTP, Filesystem, PHP Classes, Compression | | | a file explorer for the web, filesystem php php3 files dirs directories pictures files windows linux system list ls scripts Categories : PHP, URLs, Directories, Filesystem | | | Easy upload class Categories : PHP Classes, Filesystem, HTTP, PHP | | | An efficient iterative and buffered text file reader Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files | | | Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text Categories : PHP, PHP Classes, Search, Filesystem | | | A function which places the path and name of all subdirectories into an array Categories : PHP, Filesystem, Arrays, Directories | | | Directory Viewer, Directory Content Viewer, Directory Structure to HTML.
This code will basically create a complete set of HTMLs to let a user
navigate through any directory you want. Excellent code for large file
sharing pages. Categories : Directories, Filesystem, PHP | | | Bs_IniHandler is a class that can read and write ini-style files (and strings) Categories : PHP, Filesystem, PHP Classes | | | Compare two texts and display a block of text with the differences between them. Categories : PHP, PHP Classes, Filesystem, Strings, Arrays | |
|
|
|