473,473 Members | 2,215 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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,

Oct 23 '05 #1
3 1920
Botan Guner wrote:
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.


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

Oct 23 '05 #2
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:
Botan Guner wrote:
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.


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


Oct 23 '05 #3
Botan Guner wrote:
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.


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

Example:

<?php
$fso = new COM("Scripting.FileSystemObject")
or die("Could not create Scripting.FileSystemObject");

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

?>
JW

Oct 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: pablo | last post by:
Dear News Groupers, I'am trying to send a php array with a hidden input field from a form to another script. The array is NOT made directly by way of <input name="arrayname" />. The array is...
7
by: bass-man | last post by:
I am trying to include a dynamically changeable file in my website with PHP and Javascript so I am using a hidden field to hold the name of the file I want to include, and I am using the$_GET...
1
by: wurlds_wurst_coder | last post by:
I want to create a directory structure and would like the folder attributes set to hidden. How can I do this and will my program be able to insert and delete files when this attribute is set. ...
2
by: karteikarte | last post by:
hey, i just found this riddle somewhere in the net: <meta http-equiv="Pragma" content="no-cache"> <script language="JavaScript"> <!-- function nstie(){return false}function...
3
by: Dale | last post by:
Is there a way to determine the number of hidden files/directories within a directory? This is what I’m doing now: System.IO.DirectoryInfo rootPath; System.IO.FileSystemInfo dirs, files; int...
1
by: YANSHOF | last post by:
hi i trying to open some new folder in my program , i write this function below , but i dont know how to make the folder "dataFile" to be hidden. bool CPoliceDBApp::changeDirectory() { char...
2
by: alex | last post by:
I need to set a directory with hidden and/or system attribute from my c# code. Similar to what is c:\RECYCLER folder set to in WinXP. So it is not visible to a user with default "Folder Options". ...
3
by: Christian Blackburn | last post by:
Hi Gang, All I want is to be able to search a file for files matching a certain criteria. However, VB seems heart set on returning hidden folders along with my list of files. I've tried the...
6
by: CodeRazor | last post by:
I loop through all the folders in a directory. I want to be able to check if a folder is set as hidden. I've been playing around with FileAttributes, see below. But its not working....
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.