5

Basically what it says on the tin:

if(is_dir($dir))
    echo $dir . " is a directory\n";

if(is_readable($dir))
    echo $dir . " is readable\n";

if($this->handle = opendir($dir))
    echo $dir . " opened\n";

Returns:

\\HTPC\MOVIES is a directory

\\HTPC\MOVIES opened

Which is wierd? I can iterate through the files in the directory but apparently it is not readable. It doesn't really matter as like I said I can still read the files, however I just find it a little odd.

Does anyone have any thoughts?

Aydin Hassan
  • 1,465
  • 2
  • 20
  • 41
  • What is the OS on "HTPC" machine? Is it windows? – Sgn. Jun 03 '12 at 12:46
  • I'm not sure, but maybe its because of Windows file system (FAT or NTFS) You may have the permission to "list content" but "reading" is not permitted! – Sgn. Jun 03 '12 at 12:53
  • What are you running on? IIS? – Ja͢ck Jun 03 '12 at 12:54
  • just running xamp on another computer, I guess it must be some sort of permission problem as another directory on a different drive on the same computer returns true for all 3 checks :/ – Aydin Hassan Jun 03 '12 at 12:56
  • Even thought http://stackoverflow.com/questions/1153824/php-access-network-path-under-windows is refering to opendir which seems to be working for you the answer propose in that discussion might solve your problem as well. – clentfort Jun 03 '12 at 12:58
  • I'm not running as a service :/ – Aydin Hassan Jun 03 '12 at 13:08

2 Answers2

3

It seems it was a permission error. Assigned to that particular folder was a homegroup. The homegroup wasn't actually being used on the network. Upon removing the homegroup and re-adding the users group is_readable returned true. Still strange how opendir returned true but is_readable not. You surely would expect something that is not readable to fail upon open.

Thanks for your help guys.

Aydin Hassan
  • 1,465
  • 2
  • 20
  • 41
  • Interesting. `is_readable()` is just a thin wrapper around `stat`, so it was definitely some permission issue; still surprised to see that the info can be so misleading :) – Ja͢ck Jun 03 '12 at 14:26
0

Check your security policies if you want to prevent entering directory, look for bypass traversal checking or something like that.

If it is bypassing that check then one can enter directory that is forbidden by acl's, however contents can't be read.

If your ACL's is set and selected carefully and correctly for whole tree then you don't normally need to touch this.

  • Would that sort of thing not be applied to all drives and not just one? – Aydin Hassan Jun 03 '12 at 13:03
  • This is security policy feature and applies to whole system at once. It is enabled or disabled globally, it does not provide or take away real security. If your ACL's is set and selected carefully and correctly for whole tree then you don't normally need to touch this. – Sampo Sarrala - codidact.org Jun 03 '12 at 13:17