473,772 Members | 3,731 Online
Bytes | Software Development & Data Engineering Community
+ 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 1934
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. 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

Oct 23 '05 #4

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

Similar topics

4
25565
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 made by normal php code and then submitted between form-tags as echo "<input type='hidden' name=\"arrayname\" value=\"$arrayname\" />" ;
7
8762
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 function to read the hidden field, but it says the field has no value even though I have a default value in the field. So my question is how do I get PHP to read the value of a hidden field?
1
2384
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. TIA introspectre ATSIGN earthlink PERIOD net
2
4010
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 nstns(){if(document.layers){st=document.getSelection();if(st!=""&&st!=" "){window.find(" ")}setTimeout("nstns()",20)}}nstns();document.onselectstart=nstie;ondragstart=nstie;function nrcie(){return false}function
3
4977
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 numOfDirs = 0, numOfFiles = 0; di = new System.IO.DirectoryInfo(“blah”); dirs = rootPath.GetDirectories(); files = rootPath.GetFiles();
1
1179
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 buffer; if(!_getcwd(buffer,MAXSIZE)) //get now active directory
2
1538
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". Is that possible? Thanks.
3
2350
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 following: strFile = Dir(strPath, FileAttribute.Archive Or FileAttribute.Hidden Or FileAttribute.ReadOnly Or FileAttribute.System) and this which shouldn't be necessary strFile = Dir(strPath, FileAttribute.Archive Or FileAttribute.Hidden Or
6
2805
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. FileAttributes fileAttributes = File.GetAttributes(fileName); It returns a value of 34 which is not one of the values in the FileAttributes Enumeration. Anyone done this before? How can i test if its hidden or not?
0
9620
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
9454
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
10038
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9912
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8934
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 projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.