Hidden directory

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Botan Guner

    Hidden directory

    Hi everyone,

    I'm running php on win2000 server and iis. I have a script that builds
    the directory sturcture of a directory or a drive. My problem is that i
    want to find that which directories are hidden. I have looked stat()
    function but it seems that it does not return a value for being hidden
    or not.

    Thanks for any help,

  • Janwillem Borleffs

    #2
    Re: Hidden directory

    Botan Guner wrote:[color=blue]
    > I'm running php on win2000 server and iis. I have a script that builds
    > the directory sturcture of a directory or a drive. My problem is that
    > i want to find that which directories are hidden. I have looked stat()
    > function but it seems that it does not return a value for being hidden
    > or not.
    >[/color]

    The simplest way of doing this would be to use shell_exec (or exec/system)
    to invoke the command interpreter's dir command with some flags:

    $hidden = explode("\n", `dir /AH /B`);

    Note that the backtics are shortcuts for the shell_exec function.


    JW



    Comment

    • Botan Guner

      #3
      Re: Hidden directory

      Thanks, that solved my problem, but i can't keep thinking how would it
      be possible if the shell_exec is disabled from the ini file.


      Janwillem Borleffs wrote:[color=blue]
      > Botan Guner wrote:[color=green]
      > > I'm running php on win2000 server and iis. I have a script that builds
      > > the directory sturcture of a directory or a drive. My problem is that
      > > i want to find that which directories are hidden. I have looked stat()
      > > function but it seems that it does not return a value for being hidden
      > > or not.
      > >[/color]
      >
      > The simplest way of doing this would be to use shell_exec (or exec/system)
      > to invoke the command interpreter's dir command with some flags:
      >
      > $hidden = explode("\n", `dir /AH /B`);
      >
      > Note that the backtics are shortcuts for the shell_exec function.
      >
      >
      > JW[/color]

      Comment

      • Janwillem Borleffs

        #4
        Re: Hidden directory

        Botan Guner wrote:[color=blue]
        > Thanks, that solved my problem, but i can't keep thinking how would it
        > be possible if the shell_exec is disabled from the ini file.
        >[/color]

        An alternative would be to use the COM extension (http://www.php.net/com).

        Example:

        <?php
        $fso = new COM("Scripting. FileSystemObjec t")
        or die("Could not create Scripting.FileS ystemObject");

        $dir = opendir('.');
        while ($file = readdir($dir)) {
        if ($file == '.' || $file == '..') {
        continue;
        }
        if (is_dir($file)) {
        $f = $fso->GetFolder(real path($file));
        } else {
        $f = $fso->GetFile(realpa th($file));
        }
        print $file;
        if ($f->Attributes & 2) {
        print ' [HIDDEN]';
        }
        print "\n";
        }
        closedir($dir);

        ?>


        JW



        Comment

        Working...