Page 1 of 6

Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 3:47 am
by duanemitchell
Can't install without turning magic quotes off in 3.0. I've searched around for a solution and tried a couple without success.

I created a php.ini file in the public_html with the line "magic_quotes_gpc=off", that didn't work.

Gonna open a ticket with Namecheap and see what they say.

I'd be happy to hear any suggestions.

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 10:13 am
by silicon_chip
You my friend might just be in luck , since I just spent 4 hours getting this fixed myself.

I had the Magic Quotes GPC ON and when I fixed THAT problem, I was getting install permission problems.

This was my fix, hope it helps you .

Create php.ini file with the following lines.

magic_quotes_gpc = Off
session.save_path = "/tmp"

Copy to the Installation subfolder of your site.
Let me know if it fixes your problem.

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 12:18 pm
by duanemitchell
Nice trick!!! That worked perfectly! Thanks so much!! It got me through the installation. I don't know if they are really turned off or not though? I'll check the server settings.

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 2:25 pm
by gbraanker
Didn't work for me...

anything else I could do?

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 2:53 pm
by duanemitchell
The only thing I can think of to do is open a ticket with your host and have them do it for you.

AFAIK, the only way to do this is to modify the php configuration through the use of a php.ini file. Some hosts give you access to this, some don't. Where you don't have access you have to create the file as described above and put it into the "Installation" folder.

I tried creating one at the top level of my public_html and that didn't work. It should have though it seems to me. I opened a ticket with Namecheap and they told me that is what to do but I had already used the above solution. I'm wondering if there is a cache issue of some sort?

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 6:42 pm
by alikon
from http://php.net/manual/en/security.magic ... abling.php
use of .htaccess is also an option

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 01, 2012 9:15 pm
by duanemitchell
Interesting. I did not try this
php_flag magic_quotes_gpc Off
in the .htaccess. I didn't include the "php_flag" part.

Discussion on the subject of turning magic quotes off does not seem to settle on one solution. It seems that the way php is config'd on the host server and what one can do to change that varies widely. It seems the trick is to find a thread that works for you.

What's new with the 3.0 install is that the first thing it does is check your settings and if magic quotes is on then it stops right there until it's fixed.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 02, 2012 12:56 am
by duanemitchell
php_flag magic_quotes_gpc Off
This line in the .htaccess file causes a 500 Internal Server Error.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 02, 2012 1:32 am
by duanemitchell
According to System->PHP Settings Magic Quotes is still on. Apparently the trick I used just got me through the installation.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 02, 2012 1:52 am
by duanemitchell
I'm having issues with image paths getting escaped when they shouldn't as in this thread I posted:

http://forum.joomla.org/viewtopic.php?f ... 4#p2909684

I have a MAMP install of Joomla 3.0 where magic quotes is off and I don't have this problem.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 02, 2012 4:01 am
by silicon_chip
You may have to get your host to set the Magic Quotes option to OFF

Alternatively try placing a php.ini file in each of your sub directories and see if that can fix your issue.
Not sure it will work, but might be worth a try in the short term.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 02, 2012 4:02 pm
by duanemitchell
I got a solution with the help of support at Namecheap. I added this line to my .htaccess:

Code: Select all

suPHP_ConfigPath /home/username/public_html
where username is my cPanel login username.

This was AFTER I used the cPanel tool "Tweak php.ini". That created a full featured php.ini file at the top level of public_html. That had magic quotes on, I set them to off. Then the above .htaccess addition worked to apply that php.ini config to the entire directory.

So I guess, for me on Namecheap as a host, my Joomla 3.0 install procedure would be to create the php.ini with magic_quote_gpc off and then add the above line to .htaccess.

If that doesn't work then I'll use the trick mentioned above of adding the 2 line php.ini to the installation folder, run the installation, then do the above 2 steps.

Re: Magic Quotes GPC Off ?

Posted: Wed Oct 03, 2012 11:08 am
by humvee
[Mod note: Glad you managed to resolve it for yourself. Thank you for providing your solution to this issue for others to see.
Marked Resolved]


When you create a local php.ini as originally indicated and added it to the joomla_root/ directory you must also add a copy to the joomla_root/administrator/ directory too, that way both the site index.php and the administrator index.php are working from the same song sheet!

Re: Magic Quotes GPC Off ?

Posted: Thu Oct 04, 2012 4:45 pm
by acim68
Yes... It works nice to turn off magic Quotes... in my case there is a Installatron Aplication Installer that install the last version of several programs.

But the magic Quotes where On, and then I had the version install but with the problems. I did put the php.ini in Administrator folder. Work fine.

Thanks a lot for your tips….!!!
:)

Re: Magic Quotes GPC Off ?

Posted: Fri Oct 05, 2012 2:08 pm
by acim68
Thanks a lot..... I just want to know and get familiarize with the new release of Joomla 3.0. But I keep working with my Joomla 2.5.7 version!!! Thanks you for your suggestion!!!

Re: Magic Quotes GPC Off ?

Posted: Sat Oct 06, 2012 12:21 am
by silicon_chip
An addendum to my original solution to getting Joomla 3.0 to install.
The following is a multiple step solution to
1. Install
2. Turn Magic Quotes off

Step 1.
Copy your Joomla 3.0 folders to your webhost
Create a php.ini file with the following lines:

magic_quotes_gpc = Off
session.save_path = "/tmp"

Copy the php.ini file to your /installation subfolder on your webhost.
(You may or may not need the session.save_path line and you might need to edit it for the specific location of the /tmp folder on your webhost)

Now you should be able to go to your browser , open your website and have Joomla think magic quotes is off. (It isn't really, but this will let you install at least.)
Proceed with your install.

Step2.
Go to the root folder of your website and create a php.ini file
Add the following lines:

magic_quotes_gpc = Off
magic_quotes_runtime = Off
magic_quotes_sybase = Off

Next we need to edit/create a .htaccess file in the root directory
it should have the following line:

SetEnv PHPRC /path /to/php.ini

The path will vary depending on your webhost
For example on my own site it is set as follows:

"SetEnv PHPRC /home/username/public_html/php.ini" where the username is my cpanel username.

Now for the usual problems.
If you create a php.ini file or a .htaccess file in some editors, be aware they may add an extension to the filename.

Make sure php.ini ISN'T really php.ini.txt for example.
And don't forget the "." in front of the .htaccess

I hope this guide helps someone struggling to get Joomla working.
Hang in there, it is well worth the effort.

Re: Magic Quotes GPC Off ?

Posted: Sun Oct 07, 2012 9:35 am
by humvee
@silicon_chip Thanks for posting back with your latest solution. Just bear in mind that not everyone has access or permission to create local php.ini files on their hosting providers. Just make sure as above that the php.ini file is placed in both joomla_root/ and joomla_root/administrator/

The other solution is to find a host that configures their servers properly in the first place.

Re: Magic Quotes GPC Off ?

Posted: Sun Oct 07, 2012 4:57 pm
by schartier
Wow, thank you Silicon Chip... This works!!!

All I was missing was this...
Next we need to edit/create a .htaccess file in the root directory
it should have the following line:

SetEnv PHPRC /path /to/php.ini

The path will vary depending on your webhost
For example on my own site it is set as follows:

"SetEnv PHPRC /home/username/public_html/php.ini" where the username is my cpanel username.

Re: Magic Quotes GPC Off ?

Posted: Mon Oct 08, 2012 9:35 am
by ttt007
looking all over for this solution. Thanks ! :)

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 6:31 am
by Sponsi
Php.ini will work if the host allows custom php.ini, in most cases hosts DON'T allow this.
I think it's time to erase this idiotic thing from the installation rules.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 9:52 am
by sovainfo
Don't think removing proper error handling is the solutions to erroneous configurations. Do you really want your site users to tell you your infrastructure is wrongly configured?

Or do you want Joomla to set it off programatically?

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 10:04 am
by Sponsi
Well, but this one is something which sticks out.

Anyway, in one case 5.4 solved it, in other, CP configuration of the host.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 11:31 am
by sovainfo
Sorry, don't understand your answer, please explain.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 11:43 am
by Sponsi
This error touches something which needs editing on many hosts and not all hosts allow php.ini change.

Switching PHP to 5.4 solved this problem. The question is whether to treat this issue as an enforcerer for people to move to 5.4 or something?

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 12:29 pm
by humvee
I don't believe it is an "enforcer" rather "better practice" as selected by the developers. It was a requirement for Joomla 2.5 as well, but it seems to be more specific in 3.0 with its effects.
If there is an "enforcer" as you are referring to it, it is that magic_quotes be turned off. This can be achieved in most situations without any need to move to PHP 5.4.x but does require cooperation from the host provider.

Re: Magic Quotes GPC Off ?

Posted: Tue Oct 09, 2012 12:36 pm
by Sponsi
humvee OK, you know, I could list a few other "good practices" but this is the question of balance.
Well, 2.5 installed just fine wherever I wanted, nothing ever needed changes.

This is the main idea I'm talking about - the extent to which hosts will agree to make such changes. I was lucky I always use high quality hosts, not too cheap, etc.

Re: Magic Quotes GPC Off ?

Posted: Thu Oct 11, 2012 5:22 pm
by DesignGuy
Quick FYI, if you're updating your server to php 5.4.7, remember it affects all urls on your dedicated or vps. If you've got a 1.5 or 2.5 site on a different url, you may be just fine with installing Joomla 3.x on one url, but the older model Joomla-powered sites may (will) go kablooey. :eek:

Re: Magic Quotes GPC Off ?

Posted: Thu Oct 11, 2012 11:39 pm
by 3rdlion
All of this unnecessary server tinkering is just madness!
You CAN have Magic Quotes turned on.

a workaround Magic Quotes and Joomla 3.0

Posted: Fri Oct 12, 2012 2:08 am
by 3rdlion
I decided to move this into its own thread. Hopefully this saves some other people time in getting their Joomla 3.0 site up and running.

Preamble
I've been seeing quite a few questions relating to Magic Quotes needing to be turned off in order to install Joomla 3.0 Many of the responses ask you to alter the php.ini or edit other high level server config.

All of this unnecessary server tinkering is just madness!
You can't even install Joomla 3.0 without turning off Magic Quotes.
And its these kind of UX blocks that put Joomla so far backwards it's not even funny.

In many cases altering php.ini is just not possible (shared hosting etc).
Magic Quotes Enable sites have existed no problem alongside Anti Magic Quotes sites, so what changed in Joomla 3.0? Why should you alter your server config?

With some careful editing, you can turn the clock back to the way things used to be and use Joomla 3.0 with Magic Quotes turned ON!

Here's how to do it:
PART 1
  • Step 1 Download the latest Joomla 3.0
  • Step 2 Extract the files on your server
  • Step 3 Open your favourite PHP editor
  • Step 4 Navigate and open installation/models/setup.php
  • Step 5 Scroll down to find line 234

Code: Select all

// Check for magic quotes gpc.
$option = new stdClass;
$option->label  = JText::_('INSTL_MAGIC_QUOTES_GPC');
$option->state  = (ini_get('magic_quotes_gpc') == false);
$option->notice = null;
$options[] = $option;
  • Step 6 Comment out the code above and save the file
Now you can install Joomla 3.0 no problem.
IMPORTANT
However, Magic Quotes and Joomla's new special character escaping will cause duplicate escaping when editing/creating content. This renders anything that's not plain text incorrectly. So, we need to add one small condition to the core (this used to exist pre Joomla 3.0)
PART 2
  • Step 1 Navigate and open libraries/joomla/filter/input.php
  • Step 2 Scroll down to find line 261

Code: Select all

public function clean($source, $type = 'string')
{
	// Handle the type constraint
	switch (strtoupper($type))
	{...
	}
	// -- ADD THIS CODE HERE
	// Handle magic quotes compatibility
	if(get_magic_quotes_gpc()) $result = self::_stripSlashesRecursive($result);
}
  • Step 3 Add the code marked above to the clean function
  • Step 4 You may have noticed we're only running this when Magic Quotes is set to ON and referring to a new function called _stripSlashesRecursive. Now, we need to add that function to the class.
    Scroll to line 755 and add the following function:

Code: Select all

/**
 * Strips slashes recursively on an array.
 *
 * @param   array  $value  Array or (nested arrays) of strings.
 *
 * @return  array  The input array with stripslashes applied to it.
 *
 * @deprecated  12.1 - Sanctioned on 2012-10-09 thanks to Anton Wintergerst
 * @since       11.1
 */
protected static function _stripSlashesRecursive($value)
{
    $value = is_array($value) ? array_map(array('JFilterInput', '_stripSlashesRecursive'), $value) : stripslashes($value);
    return $value;
}
If you want to learn about why Joomla is trying to force us to disable Magic Quotes then check out this link:
http://www.php.net/manual/en/security.m ... whynot.php

Re: Magic Quotes GPC Off ?

Posted: Fri Oct 12, 2012 5:06 am
by alikon
@3rdlion
your proposal is a core hack and maybe expose joomla to high security risk

is a bad pratice to hack core code