Solved magic quotes gpc off – problem Joomla 3.0

I. Turn Magic Quotes off With PHP.ini file

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.

 

II. Hack Small joomla Core

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:
// 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:
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:
/**
* 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;
}
III. Use .HTACCESS

1) create .htaccess
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/google/public_html/ (this is path where is joomla site install)
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>

2) create
php.ini file and paste this
magic_quotes_gpc = Off
extension=pdo.so

extension=pdo_mysql.so
AND/OR
This is what worked for me… (Apache Server – Php 5.3.19)

php.ini (located in Joomla Installation folder noting that you may have to make one)

Code:
magic_quotes_gpc = Off;
session.save_path = “/tmp”;

Add to .htaccess file: (Not htaccess.txt)

Code:
<IfModule mod_suphp.c>
suPHP_ConfigPath /home/YOURINFO/public_html/JOOMLA INSTALLATION ROOT
<Files php.ini>
order allow,deny
deny from all
</Files>
</IfModule>

Verify it is off on Joomla 3+ by viewing System->System Information ->PHP Information and look for the value ‘magic_quotes_gpc’

Leave a comment