Re: [PHP] getting $_ENV variables
At 11:54 AM +0100 5/10/07, C.R.Vegelin wrote: All I want is to check the $_ENV['OS'] within PHP scripts. If all you want to do is to find out what the user's OS is, try this: $_SERVER('HTTP_USER_AGENT') Do print_r($_SERVER) to see all it contains. Cheers, tedd -- --- http://sperling.com http://ancientstones.com http://earthstones.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
tedd wrote: At 11:54 AM +0100 5/10/07, C.R.Vegelin wrote: All I want is to check the $_ENV['OS'] within PHP scripts. If all you want to do is to find out what the user's OS is, try this: $_SERVER('HTTP_USER_AGENT') Do print_r($_SERVER) to see all it contains. He wanted to tell the OS of the *server*, hence using a local environment setting. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 5:26 PM Subject: Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - *From:* Daniel Brown [EMAIL PROTECTED] *To:* C.R.Vegelin [EMAIL PROTECTED] *Cc:* [EMAIL PROTECTED] *Sent:* Wednesday, May 09, 2007 5:26 PM *Subject:* Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Daniel, I did get the result via the web / IE with the address: http://127.0.0.1/test/ENVtest.php with ENVtest.php having: ?php print_r($_ENV); ? using Windows XP, PHP 5.2.0 - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Thursday, May 10, 2007 2:24 PM Subject: Re: [PHP] getting $_ENV variables Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - From: Daniel Brown To: C.R.Vegelin Cc: [EMAIL PROTECTED] Sent: Wednesday, May 09, 2007 5:26 PM Subject: Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
What HTTP server are you using, Apache, IIS, AnalogX SimpleServer? That last one is actually one of my favorites for simple desktop page hosting. Tiny, no installation boom, there you go. http://www.analogx.com/ --- There's a bunch of stuff there. No, I'm not affiliated with them, or advertising for them. Just linking. On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Daniel, I did get the result via the web / IE with the address: http://127.0.0.1/test/ENVtest.php with ENVtest.php having: ?php print_r($_ENV); ? using Windows XP, PHP 5.2.0 - Original Message - *From:* Daniel Brown [EMAIL PROTECTED] *To:* C.R.Vegelin [EMAIL PROTECTED] *Cc:* [EMAIL PROTECTED] *Sent:* Thursday, May 10, 2007 2:24 PM *Subject:* Re: [PHP] getting $_ENV variables Cor, If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. Did you get that result when running the script from the CLI or via the web? On 5/10/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Thanks Daniel, Greg, Richard, I made a script with: ?php print_r($_ENV); ? and it results only into: Array ( ) nothing else ... So it must be caused by a different environment ? All I want is to check the $_ENV['OS'] within PHP scripts. Regards, Cor - Original Message - *From:* Daniel Brown [EMAIL PROTECTED] *To:* C.R.Vegelin [EMAIL PROTECTED] *Cc:* [EMAIL PROTECTED] *Sent:* Wednesday, May 09, 2007 5:26 PM *Subject:* Re: [PHP] getting $_ENV variables When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107 -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
I guess I really didn't understand that myself before either. So Richard, even though it's disabling data output, it still exists as an array? Well, damn you really DO learn something new every day. On 5/10/07, Richard Davey [EMAIL PROTECTED] wrote: Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! And I assume that EGPCS will also affect: ?php print_r($_FILES); ? Now with GPCS this script shows also only: Array ( ) So also potential problems with $_FILES with hosts hiding the environment settings ?! Regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 2:44 PM Subject: Re: [PHP] getting $_ENV variables Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Daniel Brown wrote: I guess I really didn't understand that myself before either. So Richard, even though it's disabling data output, it still exists as an array? The array ($_ENV) exists, it is just the population of it that has been disabled, thus it's empty. Just in the same way that doing a print_r($_GET) will always display an empty array even if the query string is totally blank, or print_r($_POST) does the same, even though you didn't post a thing to the script. The super-globals I guess must just be created at run-time, and populated later on in the process, by which time the php.ini settings have been taken into account and stopped the action. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
2007. 05. 10, csütörtök keltezéssel 16.05-kor C.R.Vegelin ezt írta: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! And I assume that EGPCS will also affect: ?php print_r($_FILES); ? Now with GPCS this script shows also only: Array ( ) So also potential problems with $_FILES with hosts hiding the environment settings ?! $_FILES is only available when you upload a file to the script with a form whose enctype is set to multipart/form-data otherwise it is empty of course I think this has nothing to do with $_ENV and the above situation... greets Zoltán Németh Regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 2:44 PM Subject: Re: [PHP] getting $_ENV variables Daniel Brown wrote: If it's suggesting that it's an array, that's a little baffling, because that means there are multiple entries (at least two), but they appear to either be null or otherwise unable to display. The $_ENV superb-global contains an array of environment settings, so it's not totally baffling that print_r() on it should return an array. The reason it is empty is because the variables_order setting in the php.ini has had it disabled. The default is: variables_order = EGPCS But it must have been changed to: variables_order = GPCS Dropping the E (Environment variables) will cause a print_r($_ENV) to be totally empty. Some hosts do this in order to hide the environment settings because they can contain sensitive information such as the CPU identifiers, etc. I've seen the 'cheaper' hosts (especially those hosting on Windows and/or Virtual Servers) disable this so you can't tell what kind of CPU they're using, or where their system drive is. Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
C.R.Vegelin wrote: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! Correct. Sucks I know, but some hosts just do this. And I assume that EGPCS will also affect: ?php print_r($_FILES); ? No, $_FILES isn't part of the Environment list, it's created again at run-time when a file upload occurs. It would be worth running a test to see if they have tied it to the $_POST array, i.e. remove the 'P' from EGPCS and see if $_FILES gets lost with it. I would be curious to know, although I can't think of a single host that would be stupid enough to disable $_POST :) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
Okay, I will use getenv() and keep variables_order = GPCS in php.ini Thanks all and with regards, Cor - Original Message - From: Richard Davey [EMAIL PROTECTED] To: [EMAIL PROTECTED] php-general@lists.php.net Sent: Thursday, May 10, 2007 3:34 PM Subject: Re: [PHP] getting $_ENV variables C.R.Vegelin wrote: Yes, my PHPinfo shows under configuration: variables_order = GPCS I will test EGPCS setting in php.ini But that also means that code using $_ENV cannot be run with hosts hiding the environment settings ?! Correct. Sucks I know, but some hosts just do this. And I assume that EGPCS will also affect: ?php print_r($_FILES); ? No, $_FILES isn't part of the Environment list, it's created again at run-time when a file upload occurs. It would be worth running a test to see if they have tied it to the $_POST array, i.e. remove the 'P' from EGPCS and see if $_FILES gets lost with it. I would be curious to know, although I can't think of a single host that would be stupid enough to disable $_POST :) Cheers, Rich -- Zend Certified Engineer http://www.corephp.co.uk Never trust a computer you can't throw out of a window -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] getting $_ENV variables
Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor
Re: [PHP] getting $_ENV variables
When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Of course, that doesn't necessarily stop ? passthru('uname -a').\n; ? or checking the $_SERVER['SERVER_SIGNATURE'] variable for the OS information so perhaps this response is just one of those white-bread responses. Something to chew on, but you really don't get anything from it. On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: Hi All, I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. TIA, Cor -- Daniel P. Brown [office] (570-) 587-7080 Ext. 272 [mobile] (570-) 766-8107
Re: [PHP] getting $_ENV variables
On 5/9/07, C.R.Vegelin [EMAIL PROTECTED] wrote: I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. You can get it other ways: php -r 'system(set|grep OS);' HOSTNAME=neptune.local HOSTTYPE=powerpc OSTYPE=darwin8.0 POSIXLY_CORRECT=y -- Greg Donald http://destiney.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
On Wed, May 9, 2007 11:57 am, C.R.Vegelin wrote: I get nothing when using: echo $_ENV['OS']; Also nothing when using: print_r($_ENV); However, phpinfo(); show a full list of ENV settings. How to get $_ENV variables ? I am using PHP version 5.2.0. If phpinfo() shows them, then that is what is there... There's nothing magical about phpinfo() function. It doesn't do much more than your print_r($_ENV) So unless you are running your script in a *DIFFERENT* environment (e.g., CLI or CGI versus Apache Module) you ought to see the same things if you spell $_ENV correctly... You can't even mess up variable scope, since it's a superglobal... No, wait... I think if you write it as a function and then declare $_ENV as 'global' you might actually manage to mess up and end up with your own $_ENV instead of the real one... Never tried that, but it might break it. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] getting $_ENV variables
On Wed, May 9, 2007 11:26 am, Daniel Brown wrote: When I print_r($_ENV); from the CLI on 5.0.4 I get a bunch of results, no problem but no $_ENV['OS'] variable. Further, when I check my phpinfo(); output, there are even fewer $_ENV variables printed than the CLI offers. CLI and CGI and Apache module *are* different environments. Different things will be available to ENV when PHP runs. I'm not certain about this, Cor, but my guess is that PHP 5.x.x may have altered the default $_ENV output to hide some of this information --- which is a good thing, in my opinion, because then you won't just have some run-of-the-mill script kiddie checking out the details of a box for known security holes. Almost for sure, PHP just blindly passes on anything you are stupid enough to have crammed into ENV... :-) I doubt that it strips out anything, for any reason. -- Some people have a gift link here. Know what I want? I want you to buy a CD from some indie artist. http://cdbaby.com/browse/from/lynch Yeah, I get a buck. So? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php