Register_globals is set to off and still get error message

Hi... I have set the register_globals to off and I can't install zenphoto:

http://tiagotavares.eu/foto/zp-core/setup.php

php info:
http://tiagotavares.eu/foto/zp-core/1.php

Comments

  • First, why do you say you cannot install Zenphoto? The screen shot you provide shows only warning messages, no errors.

    But to address the warnings. Generally they tell you what you would need to do to rectify the warning.

    The first describes what to do to have setup detect your filesystem character set. Of course, if you know, you can set it directly. Your php info link is broken, but most likely the characterset is iso-8859-1. Anyway, so long as you do not use diacritical marks in file/folder names there is no problem (as the warning states.)

    You have several warnings saying that Zenphoto is unable to set file/folder permissions. Currently the permissions are not very secure. However, note that servers that are set this way often do not work when you set the permissions properly. The warning message points you to a troubleshooting guide on this.

    The secons warning simply states that setup does not think you are running on an Apache server. That may or may not be an issue. Apache servers are the only ones we are in a position to provide support suggestions for. But Zenphoto has been successfully installed on other servers. You can post what you are using and maybe someone here can help.

    The last unique warning says that Zenphoto could not create the robots.txt file. That file is not needed, but the fact that we could not create it probably means there is a permissions issue.
  • Hi... removed the php check from the setup.php file so that I could continue installing zenphoto.. that's why other warning started showing up...

    Now, I get a different error.. it has to do with the Mysql query... http://tiagotavares.eu/foto/zp-core/setup.php
  • If you try again, you'll see the php register globals problem I was talking about. I talked with the system manager and he said register globals are off, both local and master...
  • 1. Your site manager must be lying to you.
    2. There is no MySQL error indication from setup
    3. Your PHP ini link is still broken
    3. You have exactly one more post to convince me that this thread in not just an elaborate attempt to use the Zenpoto site to promote your web page SEO. Should you fail, this thread and your user ID on the site will be deleted.
  • No, this isn't an attempt to do that, don't need that kind of promotion... I've grabbed a screenshot with the error that I still get:

    https://picasaweb.google.com/lh/photo/eVoOhbQvtG1YEmp5PlWKUA?feat=directlink

    It says register globals is set to ON and it isn't! It's set to off...
  • acrylian Administrator, Developer
    I have no idea, either it is not disabled (maybe your host does not allow to change that value?) or it reports wrong. Best you contact your host.
  • More to the point. Your PHP is reporting that the option is on. It will not do that unless the option is indeed on. If your host says he turned it off and it still reports that it is on, then your host did not actually turn it off. No other explaination.

    So, contact your host. Make him prove he has set it off--a simple PHP script can do this (as is done by setup.) Probably also this can be confirmed by the PHP info function.
  • The php script shows register_globals as being off..

    http://tiagotavares.eu/foto/1.php
  • add a line to setup.php after the line that reads
    `
    $register_globals = ini_get('register_globals');
    `
    [circa line 427] add:
    `echo '
    $register_globals ';var_dump($register_globals);`

    and report what it displays.
  • What that message is saying is that register_globals is on and you need to turn it off. Do this by editting your php.ini file if your host allows it, or contact your host for help. Sometimes a host will allow you to change some of the settings via the php.ini file, but not all of them.
  • Actually, what this is saying is that your hosting provider s incompetent. The setting of register_globals was made to the string `"off"` [note the quotation marks. This is not at all the same as setting it to the constant `off`. Instead it is equivalent to setting the variable to `on` or `true`,

    So set it to `off` [no quotes] and it will indeed be not set.
  • They say they have checked all settings and all configuration files/.htaccess file has this option without quotation marks:

    [root@linux2-whg httpdocs]# cat .htaccess
    php_value magic_quotes_gpc off
    php_value register_globals off
    php_value short_open_tag off

    "If these PHP settings were wrong, you would not be able to see that register_globals was set to off through phpinfo() function. So I think the issue is with particular application, not server settings."
  • Get a new provider. If set without the quotes it will work. If set with the quotes it will be on. Plain and simple. What you saw with the var_dump function is EXACTLY what the option was set to. If you use off without quotes the option will show as an empty string.

    Sorry, but this one is really on you and your provider. You will notice that no one lse is reporting that they also have this problem.
  • A bit more on this topic.

    First my feeling: sbillard, I found you pretty arrogant and unfair with mrtavares who was just trying to make zenphoto work on his host. Contrary to what you say, he is not alone reporting this problem: I just spent my morning fighting against it, and another post has been submitted a week ago on the very same topic (http://www.zenphoto.org/support/topic.php?id=9573#post-56312).

    A bit of history: the line that causes trouble has been introduced in setup.php at revision 7059 in the development branch of zenphoto. It has been merged into the trunk at revision 7176 in the middle of May. I do not know precisely when it has been officially released but anyway, this is three times the same report, for a bug (call it a feature if you want) that has been introduced less than 2 months ago. So, please, consider that the problem might also come from you before insulting people.

    That said, I recognize that the behavior of php is a bit troubling here. According to the commented lines at the beginning of my php.ini (php version 5.3.3-7, from a Debian distribution), the allowed keywords for boolean flags are: 1, true, yes, on, 0, off, false, no. Experiments seem to show that these keywords are key insensitive. When one uses one of this keyword, everything is fine.

    Now, what happens, if some other keywords are used?
    * a non-zero integer seems to be considered as true, as it is everywhere in PHP.
    * Things become weird when strings are used: the strings "on", "true", "yes", "17", etc. (case insensitive) are considered as on.
    * Any other non-empty string (or an invalid keyword, such as onnn, without quotes) yields the following behavior: (bool)ini_get('register_globals') returns true (as you could expect for the boolean cast of a non-empty string) *but* register_globals is actually deactivated (I mean that the variables in $_GET, $_POST, etc. are *not* registered as global variables). Moreover, phpinfo() indicates that register_globals is Off (both local and master).

    In conclusion: clearly, using something else that the recommended keywords is bad and should be avoided by hosts. *But* the behavior of php is indeed such that the string "on" activates register_globals and the string "off" deactivates it. So it is not surprising that many site managers do the mistake, since it works in practice as expected.
    Finally, it seems to be considered as poor practice to do what is done in zenphoto (i.e. just test the boolean value of ini_get('register_globals')). About it, see the comments of "nicolas dot grekas+php at gmail dot com" at the official manual page of ini_get: http://www.php.net/manual/en/function.ini-get.php
  • acrylian Administrator, Developer
    Finally, it seems to be considered as poor practice to do what is done in zenphoto (i.e. just test the boolean value of ini_get('register_globals')).
    We always appreciate pointers to best practices. We certainly neither claim to nor do know everything.

    But we also can't know what works on some host and on some not if you don't use the recommended keywords. (register globals should simply off by default anyway...)
  • You have an interesting perspective on "best practices". This it the first time I have ever heard that it is a best practice to rely on what is at best an undocumented behavior.

    As likely is that it may be an implementation specific anomaly. The PHP ini documentation clearly distinguishes constants from strings. The statement for booleans is

    ; Boolean flags can be turned on using the values 1, On, True or Yes.
    ; They can be turned off using the values 0, Off, False or No.

    Nowhere does it suggest that the string “Off” is equivalent to the constant `Off`. Are you sure that this is the case in all versions of PHP past and future? Are you indemnifying anyone who relies on this and is subsequently hacked by a security breach?

    Seems to me that best practice is to use the constants as defined. Any provider not willing to do that should be viewed with some concern.
  • Nowhere does it suggest that the string “Off” is equivalent to the constant Off
    You are absolutely right. This is nowhere suggested. Nor is documented what is the behavior of PHP on non-empty string. Indeed, what I consider as bad is the behavior of PHP that makes a difference between the strings "on", "yes", "true" and other non-empty strings. But the fact is that, at least for some versions of PHP, there is a (undocumented) difference.
    Are you sure that this is the case in all versions of PHP past and future?

    Certainly not. But on recent versions of PHP, it seems to work this way. My remark is just that three people reported the same problem, within three weeks, for a release of zenphoto that has been published on June 21. Considering that very few people actually report bugs, I see this as a serious issue. The fact is, that you can ask people to use recent versions of PHP, but you cannot blame them if their providers use undocumented (but fully functional) behaviors. Whether you like it or not, when they set register_globals to "off", they actually deactivate register_globals, and due to poor specification of PHP, you cannot rely on the boolean value of ini_get to know if it is activated or not.
    Seems to me that best practice is to use the constants as defined. Any provider not willing to do that should be viewed with some concern.
    You are completely right. It *is* bad practice to use strings instead of keywords to set register_global (and I made a bug report to my provider as well). But I am just saying that it is not fair to forbid the installation of zenphoto on servers on which register_globals is deactivated, just because it has been deactivated with an undocumented keyword. I would recommend to display a serious warning, and tell people to contact their site managers, but not stop the installation process.

    I was just giving you the link to the documentation of ini-get to show you that other people already thought about the way of testing if register_globals is activated or not, and they concluded that the "good" way of doing is not to simply test the boolean value. Call it "good practice" or not, it is what people do, when they want to have a test that just works.
  • Sorry for the previous message. It seems that I forgot to close a blockquote markup.

    I thought of another (robust) way of deciding whether register_globals is activated or not: read the "Local" field of the corresponding row in the table returned by phpinfo(). Something like the following function do the trick (I do not claim the following code to be very robust though, because it will be broken if the output of phpinfo is formatted a bit differently; but you certainly can write more robust code for doing the same thing).

    function register_globals_from_phpinfo() {
    ob_start();
    phpinfo(INFO_CONFIGURATION);
    $pinfo = ob_get_contents();
    ob_end_clean();

    preg_match('#<tr><td[^>]*>register_globals.*#', $pinfo, $match);
    if (count($match) != 1) return -1;

    $line = $match[0];
    $value=strtolower(preg_replace('#<tr><td[^>]*>register_globals</td><td[^>]*>([a-zA-Z]*)<.*#', '${1}', $line));
    if ($value == "off") return 0;
    else return 1;
    }
  • Sure, we could do this for each and every ini_get() we use. But then what is the point of ini_get()? Seriously, the solution for this problem is as posted. Be sure the PHP.ini file has set the option to the proper constant. (Note also that the other thread you reference is really not the same. In that case the problem was caused by incorrect case in the "constant" so the feature was indeed on as reported.)

    Bottom line is that Zenphoto will report the settign of the ini_get(). If in some cases that does not match the actual enable of the feature at least we know we will error on the conservative side. There is really no justification for using a sledge hammer to kill this fly.
  • But then what is the point of ini_get()?
    In fact, the more I think about it, the less I believe that you correctly use ini_get. I just read again the documentation. It is explicitely written
    Note: When querying boolean values
    A boolean ini value of off will be returned as an empty string or "0" while a boolean ini value of on will be returned as "1". The function can also return the literal string of INI value.

    I understand it as "a ini value of off will usually be returned as an empty string or '0', but might also be returned as the string 'off'." So you cannot just convert it to a boolean but you have to test the string, as suggested in the comments by "nicolas dot grekas+php at gmail dot com". Please note that there is also another remark by "filh at filh dot org" that says pretty much the same:
    Important: The manual says that ini_get will return 0 [...]. This is technically correct, however when you use [...] in an .htaccess file, ini_get will return the string, which will "evaluate" to 1.
    Please also note that all the comments about boolean values in the manual page of ini_get are about register_globals. This problem is usual and well reported. The way you handle it (as correct as it can be from a purist point of view) is not the recommended way.
    (Note also that the other thread you reference is really not the same. In that case the problem was caused by incorrect case in the "constant" so the feature was indeed on as reported.)
    I am really not sure. When testing the string returned by ini_get, they all apply strtolower first which suggests that the keywords are case insensitive. In my opinion, the problem reported by 100cccer is exactly the same problem: the keyword used was Off, which indeed deactivated register_globals but was returned as "Off" by ini_get. It has been changed into off, so that ini_get now returns an empty string. But most likely, register_globals was in fact deactivated from the very beginning.
  • In the PHP package distributed with my Debian distribution, the default settings in php.ini are given with keywords beginning with an upper-case (e.g., Off, and not off). It seems fairly clear to me that the keywords are case insensitive and the problem reported in the other thread by 100cccer was not a problem of case.
Sign In or Register to comment.