<?php
# =============================================================================
# Create
# name : Andre Rikkert de Koe date: apr 2011
# descr : filefind
# This is a demo of programming in the PHP language (CLI).
# Its part of a project to implement a program to create a directory
# tree similar to the output of the Unix find program.
# EUID : Any user who has read access to all the files being searched for.
# run : interactive
#
# Changes
# name : date:
# descr : short description
#
# =============================================================================
# =============================================================================
# Functions
# =============================================================================
function Usage($progname ,$mesg)
{
echo "Usage: $progname directory\n";
echo "$mesg\n";
}
function traverse($dir)
{
# http://php.net/manual/fr/function.readdir.php
while (false !== ($file = readdir($myDirectory)))
{
$pfile = $curdir2 . "/" . $file;
{
if ($file != ".." && $file != ".")
{
echo "$pfile\n";
traverse($file);
}
}
else
{
echo "$pfile\n";
else
echo "WARNING: Could not process file $pfile\n";
}
}
}
function start_traverse($directory)
{
echo "$directory\n";
traverse($directory);
}
# =============================================================================
# MAIN
# =============================================================================
$progname = $argv[0];
if ( $argc == 2 )
{
$directory = $argv[1];
start_traverse($directory);
else
Usage($progname, "ERROR: Not a directory : $directory");
}
else
Usage($progname, "ERROR: 1 argument expected");
?>