php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #1349 readdir and $d->read return blank filenames
Submitted: 1999-04-26 12:22 UTC Modified: 1999-06-01 15:27 UTC
From: p_ross at hso dot link dot com Assigned:
Status: Closed Package: Misbehaving function
PHP Version: 3.0.7 OS: IRIX 6.2
Private report: No CVE-ID: None
 [1999-04-26 12:22 UTC] p_ross at hso dot link dot com
The following script

<?php
$fileno = $column = 0;
$TDopen = array ( 0 => "\n<TR><TD>\n", 1 => "\n</TD><TD>\n", 2 => "\n</TD><TD>\n
");

$Book_Of_Spells = "/usr/localhost/apache/share/htdocs/admin/pages/book_of_spells
";

$B_O_S = dir ( "$Book_Of_Spells/RCS" );
echo "Handle: ".$B_O_S->handle."<br>\n";
echo "Path: ".$B_O_S->path."<br>\n";
while ($filesname = $B_O_S->read())
{
   if (ereg ( "html", $filename ))
   {
      $name = split (",", $filename);
      $title = passthru (`rlog -t $Book_Of_Spells/$name[0] | grep -v \":\" | gre
p -v \"^=====\" | grep -v \"^\$\"`);
      print $TDopen[$column++];
      print "<FONT SIZE=-2><A HREF=\"$Book_Of_Spells/$name[0]\">$title</A></FONT
>";
   }
   else
   {
      print $TDopen[$column++];
      print "File No. ".++$fileno.":".$filename;
   }
   if ($column == 3)
   {
      $column = 0;
      print "\n</TD></TR>";
   }
}
if ($column != 0)
{
   for ($i=$column; $i<3; $i++)
   {
      print "$TDopen[$i]";
      print "&nbsp;";
   }
   print "\n</TD></TR>";
}
$B_O_S->close();
?>

spits out the correct pathname and the correct _number_ of filenames, but they are all blank.  I have no doubt that I am doing something wrong, but I can't find it.  I followed the opendir/rewinddir/readdir examples first  but couldn't tell what was really going on.  When I switched over to the class examples I finally got the pathname and found that it was correct.  This was a perl script and I'm trying to convert it over to php3.  Haven't even gotten to debugging the passthru.  One thing at a time.

I neither compiled nor installed php3, but, if you could tell me what you need, I'll be glad to provide it (the httpd.conf and php3.ini files are a bit big for attaching if you don't need the whole thing).

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [1999-06-01 15:27 UTC] jim at cvs dot php dot net
There is a typo in your script.

The while expression should read "$filename = $B_O_S->read()",
but you've misspelled it filesname.
 
PHP Copyright © 2001-2026 The PHP Group
All rights reserved.
Last updated: Tue Jun 30 10:00:01 2026 UTC