WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : PHP4 DirectoryIterator Class
Categories : PHP, PHP Classes, Filesystem, Directories Click here to Update Your Picture
Adrian Rotea
Date : Jun 11th 2005
Grade : 3 of 5 (graded 6 times)
Viewed : 11359
File : 4180.php
Images : No Images for this code example.
Search : More code by Adrian Rotea
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?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;
            }
        }       
    }   
}
?>



Remote Archive (Zip, Tar, Gzip) downloader with FTP and local extration support
Categories : PHP, FTP, Filesystem, PHP Classes, Compression
filesplit : Split big text files in multiple small ones
Categories : PHP, Log Files, Filesystem, PHP Classes
A File Browser Class.To Read Drives,Directories and Files .Files writing is also possible
Categories : PHP, PHP Classes, Filesystem
Bs_IniHandler is a class that can read and write ini-style files (and strings)
Categories : PHP, Filesystem, PHP Classes
List the content of the directory of your webserver where this small PHP Script resides.
Categories : PHP, Filesystem, Directories, CSS
An efficient iterative and buffered text file reader
Categories : PHP, Classes and Objects, Filesystem, PHP Classes, Log Files
grab directory listings into an array the example prints out each subdirectory in the main dir - further work is to be performed on this one
Categories : Filesystem, PHP, Directories, Search, Utilities
file class , uploade file , download file already uploaded on another website
Categories : PHP, PHP Classes, Filesystem, Web Services
Directory TreeView - File Manager & Explorer - FTP - Utility - PHP/HTML -
Categories : PHP, Directories, FTP, Filesystem, HTML and PHP
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
Search and Replace Text : Searches Files for Specified Text and Replaces It by a Given Text
Categories : PHP, PHP Classes, Search, Filesystem
Easy upload class
Categories : PHP Classes, Filesystem, HTTP, PHP
PHP Transfer data from text file to Mysql Table
Categories : PHP, PHP Classes, Filesystem, Databases, MySQL
Directory viewer, customize how you display the file structure, easy to understand. Found out about PHP 3 days ago, and this is my first prog.
Categories : HTML and PHP, Complete Programs, Directories, Filesystem, PHP
getDirArray(Path,Filter,Sorted): Returns an array of the files in a directory, filtered by regular expression and either sorted or randomized. Good for random pictures and graphics.
Categories : PHP, Filesystem, Directories