We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 21395
    • 91 Posts
    My Hosting ISP has just upgraded to PHP5.3.4, and I am now bedevilled with the Magic Quotes problem: every double quote that I type into a template or chunk (as in <div id="leftcol">) is now rendered as <div id=\"leftcol\">.

    (Here’s not the place to whine about "php deprecation" apparently meaning the opposite).

    My ISP apparently runs PHP as a CGI, so putting
    php_value magic_quotes_gpc 0
    into .htaccess will not work. I have to put
    magic_quotes_gpc = Off
    into a file called "php.ini", and apparently I have to put a copy of this into every sub-directory that has scripts in it.

    Nightmare.

    Firstly - is it true that I have to do this?, and;
    Secondly - if so, is there a shortcut, and can I just put it, say, in .../manager/includes?


    I have sites running 9.6.3 through 9.6.7, 1.0.2. 1.0.4. and 1.0.5 (and am in the process of upgrading them all to 1.0.5, as I write: the ISP’s PHP upgrade is breaking lots of other things too).

    PHP 5.3.4,
    MySQL 5.1.54,
    Apache 1.3.42,
    I’ve no idea what pdo_mysql is, but the configuration command in php-info says "pdo-disabled" and
    I use Firefox.

    Any tips much appreciated.




    Yours


    Nic Boyde
      MODX Revolution 2.6.5-pl (traditional)

      Hosted on MODX Cloud

      Skype: nicbaldeagle
      • 2740
      • 95 Posts
      When I had that problem my host told me the same, but if I remember correctly I simply placed it in my manager directory: manager/php.ini

      One way to check the location of your php.ini is Reports > System Info > phpInfo() View - and in your php configuration look for ’Loaded Configuration File’.

      My php.ini file consists of:

      magic_quotes = off
      magic_quotes_gpc = Off
      magic_quotes_runtime = Off

      Obviously you’ll still have to edit the pages and chunks already effected.

      pdo_mysql really only applies to Revolution.
        • 36493
        • 64 Posts
        You be able to set your PHPRC in your .htaccess file then you only need one php.ini file

        eg.
        SetEnv PHPRC /var/www/vhosts/domain.tld
        


        SetEnv PHPRC path-to-php.ini-file.
          |
          • 21395
          • 91 Posts
          Thank you both for your suggestions - but no dice. Something does happen though.

          If I put the php.ini file in .../manager ,or in .../manager/includes, then the manager logon screen stops working. The password is accepted, the page refreshes, and I get the logon screen again.

          If I put the php.ini file in /public_html, this isn’t the case ,and the logon screen returns to normal behaviour - but I the magic_quotes problem is still there..

          If I put the php.ini file in /public_html and set the PHPRC environment variable to point at the php.ini file - I get the blocked logon screen again. If I comment out the new line in .htaccess, then back to normal. By "normal" I mean back to the status quo: I can login without problem, but I have the magic_quotes problem still.


          This is something that probably rests with my ISP, but they aren’t MODx people, and their view is that it’s my problem, not theirs.

          I’m using 5dollarhosting.com, just in case there are any fellow sufferers out there.

          Thanks again for the suggestions - any more ideas?



          Nic Boyde
            MODX Revolution 2.6.5-pl (traditional)

            Hosted on MODX Cloud

            Skype: nicbaldeagle
            • 2740
            • 95 Posts
            I’ve no idea why you would have login problems simply by having a php.ini file. For me the CGI is the unknown factory in this.

            I’ve rechecked my settings for when I had a Magic Quotes issue. I’ve only got two php.ini files, one in the root directory (public_html - not sure if this is really needed) and one in the manager directory. They both contain the three lines listed above and I didn’t make any changes to .htaccess for Magic Quotes. My host server default php.ini setting has magic quotes to off.

            I would contact your host and ask if magic_quotes are turned off by default then retry with two php.ini files, one in the root and one in the manager directory and remove any magic quote commands from .htaccess.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              php.ini files are not inherited; you need to have one in every directory where the default server settings need to be overridden. In the case of MODx, that’s the /manager/ directory; all the Manager functions are performed by the index.php file which simply includes() the others. If you had, say, an AJAX processor file somewhere else that saved anything you would need one wherever that file existed, which is another excellent reason for using a resource with a snippet as your AJAX processor. In that case, you’d need a php.ini file in the site root directory as well to cover the main index.php file.

              If PHP is running as CGI, this means it’s not an Apache module but an actual stand-alone PHP interpreter. In this case, .htaccess would not have any effect on the PHP configuration since that is an Apache configuration override.

              A hosting service that cannot give a simple answer to such a simple problem as turning off magic_quotes_gpc is not one I would have very much faith in.
                Studying MODX in the desert - http://sottwell.com
                Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                Join the Slack Community - http://modx.org
                • 21395
                • 91 Posts
                Dear Susan and Stratton

                I have established the following:

                a) My hosting company runs php as a cgi. (First I’d head about the idea, but I understand it isn’t without merit). The upshot is I can’t use .htaccess, which was one of the helpful suggestions. I have to use php.ini

                b) php.ini files aren’t recursive - that is, don’t have any effect if for some reason control passes to a new sub-directory which hasn’t got a copy of php.ini

                c) Except that my host now tells me, while studiously avoiding the real issue, that I can add the following to .htaccess: SuPHP_ConfigPath /path/to/public_html/php.ini, whereupon two things happen - the php.ini file in that location apparently becomes recursive, and what’s more the php-as-cgi thingy knows which order to read the two php.ini files - the local one and the main one, which is hidden away in country I am not permitted access to.

                d) Their advice is worthless. The addition to .htaccess crashes everything, I get an Internal Server Error page generated by MODx which also reports a 500 Internal Server Error. Reversing the .htaccess file to its former status brings things back to normal.

                e) There is still an unresolved issue with MODx, and I found an unanswered posting on the forums some time ago http://modxcms.com/forums/index.php/topic,30192.0.html reporting an identical phenomenon. That is: if a php.ini file is added to /manager, the login screen becomes permanent. Obviously rare, and also fairly obviously some kind of combination of MODx and hosting service. I’ll go and hunt the link and edit this later.

                f) Yes, the hosting company’s response to my query was that PHP 5.3.4 did "deprecate" magic_quotes, but deprecated it as "on". This surely cannot possibly be true. I can see some of the current configuration file in phpinfo(), and sure enough, there it is ’enable-magic-quotes’. So what gives there? Are they telling the truth? Is magic-quotes locked on and unable to be turned off because the off-switch has been deprecated?

                g) I am losing faith with them.


                I would still like to know why php.ini files make things fall over in some permutations of MODx, as there are other things that might be fun to tweak in PHP

                  MODX Revolution 2.6.5-pl (traditional)

                  Hosted on MODX Cloud

                  Skype: nicbaldeagle
                  • 1343 ☆ A M B ☆
                  • 2,213 Posts
                  Hey,

                  You might want to give these a try, use this to generate a php.ini file: http://tips-scripts.com/php_ini
                  and this will distribute it: http://tips-scripts.com/php_ini_copy

                  If that doesn’t work then you may want to consider a new hosting company, if you need some suggestions speak up I know some great hosts.
                    Patrick | Server Wrangler
                    About Me: Website | Tweets |  MODX Hosting
                    • 2740
                    • 95 Posts
                    Nic have a look at this http://bugs.modx.com/issues/3724

                    And if that doesn’t work, take up AMDbuilder’s offer of hosting suggestions.