Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: How emulate read and write chmod data for files on Windows? |
|
Author |
|
orange_python
Joined: 24 Feb 2018 Posts: 5 Location: Russia
|
Posted: Tue 06 Mar '18 19:47 Post subject: How emulate read and write chmod data for files on Windows? |
|
|
I have local and web-server Apache. When I get chmod with php function for file, application return wrong information about file. But I know that information with properties keep in the meta-data of file. Some times possible change rules of acces with Windows included utilites, but this work incorrect. Other fact. When moving files from local machine on web-hosting (or backward) not changing a really properies of file keep in it.
Is there plugin, or methodic, or the way that is understood apache server how to reading meta-data of chmod parameters?
How will made possible read and write chmod data for Apache on Windows OS?
-- sorry about my english |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7371 Location: Germany, Next to Hamburg
|
Posted: Thu 08 Mar '18 13:48 Post subject: |
|
|
On Windows you can't make use of chmod. But you can get the owner and the group.
Code: |
function getOwner($file,$path){
$GetFileOwner = "n/a";
if(getenv('windir')){
//windows
$sVerz = str_replace("/", "\\", $file);
if(!class_exists('COM')){
return 'n/a';
}
$SWbemServices = new COM('winmgmts://');
$SWbemObjectSet = $SWbemServices->ExecQuery("ASSOCIATORS OF {Win32_LogicalFileSecuritySetting='" . $sVerz . "'} WHERE AssocClass=Win32_LogicalFileOwner ResultRole=Owner");
foreach($SWbemObjectSet as $SWbemObject){
$DomainName = $SWbemObject->ReferencedDomainName;
$Account = $SWbemObject->AccountName;
$GetFileOwner = $DomainName . '\\' . $Account;
}
return $GetFileOwner;
}
else
{
//Unix / Linux
$stats = stat($file);
return $stats['4'];
}
}
function getGroup($file){
if(isset($_SERVER['WINDIR'])){
return "n/a";
}
else
{
$stats=stat($file);
clearstatcache();
return $stats['5'];
}
}
|
|
|
Back to top |
|
|
|
|
|
|