The Joomla! Forum ™



Forum rules


Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.



Post new topic Reply to topic  [ 161 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next
Author Message
 Post subject: Magic Quotes GPC Off ?
PostPosted: Mon Oct 01, 2012 3:47 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
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.

_________________
Next Generation Solutions | http://www.nxgnsol.com


Last edited by humvee on Wed Oct 03, 2012 11:08 am, edited 1 time in total.
Marked as resolved as per OP


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 10:13 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Oct 01, 2012 10:07 am
Posts: 8
Location: Qld Australia
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.


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 12:18 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
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.

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 2:25 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Sun Sep 30, 2012 9:16 pm
Posts: 3
Didn't work for me...

anything else I could do?


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 2:53 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
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?

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 6:42 pm 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Fri Aug 19, 2005 10:46 am
Posts: 5786
Location: Roma
from http://php.net/manual/en/security.magicquotes.disabling.php

Quote:
use of .htaccess is also an option

_________________
Nicola Galgano
i know that i don't know
www.alikonweb.it


Top
 Profile  
 
PostPosted: Mon Oct 01, 2012 9:15 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
Interesting. I did not try this
Quote:
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.

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Tue Oct 02, 2012 12:56 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
Quote:
php_flag magic_quotes_gpc Off


This line in the .htaccess file causes a 500 Internal Server Error.

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Tue Oct 02, 2012 1:32 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
According to System->PHP Settings Magic Quotes is still on. Apparently the trick I used just got me through the installation.

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Tue Oct 02, 2012 1:52 am 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
I'm having issues with image paths getting escaped when they shouldn't as in this thread I posted:

viewtopic.php?f=706&t=760262&p=2909684#p2909684

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

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Tue Oct 02, 2012 4:01 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Oct 01, 2012 10:07 am
Posts: 8
Location: Qld Australia
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.


Top
 Profile  
 
PostPosted: Tue Oct 02, 2012 4:02 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Wed Jan 03, 2007 3:16 am
Posts: 90
Location: Boston, MA USA
I got a solution with the help of support at Namecheap. I added this line to my .htaccess:
Code:
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.

_________________
Next Generation Solutions | http://www.nxgnsol.com


Top
 Profile  
 
PostPosted: Wed Oct 03, 2012 11:08 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 17, 2005 10:27 pm
Posts: 14715
Location: Kent, England
[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!


Top
 Profile  
 
PostPosted: Thu Oct 04, 2012 4:45 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 03, 2010 7:38 pm
Posts: 21
Location: Edo. México | México
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….!!!
:)


Top
 Profile  
 
PostPosted: Fri Oct 05, 2012 2:08 pm 
User avatar
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Dec 03, 2010 7:38 pm
Posts: 21
Location: Edo. México | México
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!!!


Top
 Profile  
 
PostPosted: Sat Oct 06, 2012 12:21 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Oct 01, 2012 10:07 am
Posts: 8
Location: Qld Australia
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.


Top
 Profile  
 
PostPosted: Sun Oct 07, 2012 9:35 am 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 17, 2005 10:27 pm
Posts: 14715
Location: Kent, England
@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.


Top
 Profile  
 
PostPosted: Sun Oct 07, 2012 4:57 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Jun 09, 2011 1:55 am
Posts: 10
Wow, thank you Silicon Chip... This works!!!

All I was missing was this...

Quote:
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.


Top
 Profile  
 
PostPosted: Mon Oct 08, 2012 9:35 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Oct 08, 2012 8:26 am
Posts: 1
looking all over for this solution. Thanks ! :)


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 6:31 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Aug 14, 2008 11:54 am
Posts: 35
Location: Warsaw, Poland
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.

_________________
http://uk.webastyczny.pl - design, corporate identity, IT projects


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 9:52 am 
Joomla! Virtuoso
Joomla! Virtuoso

Joined: Sat Oct 01, 2011 7:06 pm
Posts: 4483
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?

_________________
Issue with migrating? Include logs/joomla_update.php in your report!


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 10:04 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Aug 14, 2008 11:54 am
Posts: 35
Location: Warsaw, Poland
Well, but this one is something which sticks out.

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

_________________
http://uk.webastyczny.pl - design, corporate identity, IT projects


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 11:31 am 
Joomla! Virtuoso
Joomla! Virtuoso

Joined: Sat Oct 01, 2011 7:06 pm
Posts: 4483
Sorry, don't understand your answer, please explain.

_________________
Issue with migrating? Include logs/joomla_update.php in your report!


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 11:43 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Aug 14, 2008 11:54 am
Posts: 35
Location: Warsaw, Poland
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?

_________________
http://uk.webastyczny.pl - design, corporate identity, IT projects


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 12:29 pm 
User avatar
Joomla! Master
Joomla! Master

Joined: Wed Aug 17, 2005 10:27 pm
Posts: 14715
Location: Kent, England
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.


Top
 Profile  
 
PostPosted: Tue Oct 09, 2012 12:36 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Thu Aug 14, 2008 11:54 am
Posts: 35
Location: Warsaw, Poland
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.

_________________
http://uk.webastyczny.pl - design, corporate identity, IT projects


Top
 Profile  
 
PostPosted: Thu Oct 11, 2012 5:22 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Sat Sep 02, 2006 9:33 pm
Posts: 262
Location: Chicago, USA
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:

_________________
John Coonen
Host, CMS Expo Learning & Business Conference - http://CMSExpo.net
Managing Director, The CMS Connection - http://CMSConnection.com
Co-founder, JoomlaChicago


Top
 Profile  
 
PostPosted: Thu Oct 11, 2012 11:39 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 09, 2012 11:32 pm
Posts: 8
All of this unnecessary server tinkering is just madness!
You CAN have Magic Quotes turned on.


Last edited by alikon on Fri Oct 12, 2012 5:00 am, edited 1 time in total.
removed link to post cause merged


Top
 Profile  
 
PostPosted: Fri Oct 12, 2012 2:08 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Tue Oct 09, 2012 11:32 pm
Posts: 8
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;
}


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.magicquotes.whynot.php


Last edited by alikon on Fri Oct 12, 2012 5:02 am, edited 1 time in total.
changed title from tutorial to workaround


Top
 Profile  
 
PostPosted: Fri Oct 12, 2012 5:06 am 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Fri Aug 19, 2005 10:46 am
Posts: 5786
Location: Roma
@3rdlion
your proposal is a core hack and maybe expose joomla to high security risk

is a bad pratice to hack core code

_________________
Nicola Galgano
i know that i don't know
www.alikonweb.it


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 161 posts ]  Go to page 1, 2, 3, 4, 5, 6  Next



Who is online

Users browsing this forum: No registered users and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group