Jump to content

Recommended Posts

This must have come up before, but the search function on these (and every other forum system) is impossible to get results out of...anyway...

 

I am trying to find the surest way to get the server's operating system. All I need is "Windows"/"Linux"/"Mac"/etc. I don't need versions or whatnot. I see some of that info entrenched in $_SERVER ... but I was wondering if there is a simpler way.

 

Also...while we are at it. I have a function that changes a file's or directory's permissions with chmod. But on windows the chmod of a directory seems to do very little. There are two settings: 0777 and 0555 (read-only). 0555 still allows you to rename the directory and create files/dirs inside of it. Files have only two options as well: 0666 and 0444 (read-only). Is there any way to beef it up?

So to relate to the server OS question: I will probably just do what windows does, only give you the read-only/everything options when on Windows, and give full octal control when on other operating systems (I'm assuming Mac -- at least MacX -- uses the Unix/Linux octal system?).

Link to comment
https://forums.phpfreaks.com/topic/131419-solved-operating-system-check/
Share on other sites

So...what's wrong with using

 

echo $_SERVER['SERVER_SOFTWARE'];

 

?

 

I don't think you're going to find any kind of environment variable or global that simple says "Windows"/"Linux"/"Mac"/etc... your best bet is to just use ^ and use some regex to parse it.

well this is what I did while I was awaiting an answer...

if (false !== stripos($_SERVER['SERVER_SOFTWARE'], 'win'))

 

so... i guess that is the solution.

I don't have access to a linux box at the moment. What would linux display in SERVER_SOFTWARE?

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.