Hi there folks:
My aim is to have a system whereby users are notified when a directory has had a new file placed into it, by virtue of an incremented counter.
However; I've run into some probs with determining the difference between the current directory (where the script is executed from) and the directories I wish to traverse (to find the no. files in each)
If I remove the '@' from opendir() and readir() then the error message is:
"Warning: OpenDir: No such file or directory (errno 2) in /path/to/my/intranet/myanet/alertusers.phpon line 8
Warning: Supplied argument is not a valid Directory resource in /path/to/my/intranet/myanet/alertusers.phpon line 11"
If I append the '@' to these functoions nothing is displayed at all!
Here is the code:
//Function to get number of files by incremented counter
function get_no_files($this) {
//Change dir
$dirdef = chdir("/path/to/my/intranet/") . $this;
//'$this' = name given to each heading in the database for ANET categories and are identical to the dirnames themselves
$dir = @opendir($dirdef);//line 8
//get total number of iterations - & therefore number of files in $dir
$i=0;
while(false!=($file = @readdir($dir))) {//line11
//if files in $dir are bonafide files then increment counter
if ($file != "." && $file != "..") {
$i++;
echo "There are $i files in $this";
closedir($dir);
}
}
}
//Get all table column names & ascertain number of files in each category's directory
$fields = mysql_list_fields("$dbName", "myanet_categories", $connect);
$nocolumns = mysql_num_fields($fields);
for ($i=0; $i<$nocolumns; $i++) {
$names = mysql_field_name($fields, $i) . "\n";
//Use get_no_files() function above
get_no_files($names);
}
Can anyone give me some pointers so that I can tell the script to look in the correct directories?
Cheers.
Russ